Submission #2119729
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define MOD 1000000007 const int INF=1000000001; int main(){ int H,W; cin>>H>>W; int a[H+2][W+2]; vector<pair<int,pair<int,int>>> v(H*W); for(int i=0;i<=H+1;i++){ for(int j=0;j<=W+1;j++){ if(i==0||i==H+1||j==0||j==W+1){ a[i][j]=-INF; }else{ cin>>a[i][j]; v[(i-1)*W+j-1]={a[i][j],{i,j}}; } } } sort(v.rbegin(),v.rend()); ll num[H+2][W+2]={}; for(int i=0;i<H*W;i++){ int z=v[i].first; int r=v[i].second.first; int c=v[i].second.second; for(int j=-1;j<2;j+=2){ if(z<a[r+j][c]) (num[r][c]+=num[r+j][c]+1)%=MOD; if(z<a[r][c+j]) (num[r][c]+=num[r][c+j]+1)%=MOD; } } ll sum=0; for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ //cout<<i<<" "<<j<<" "<<num[i][j]<<endl; (sum+=num[i][j]+1)%=MOD; } } cout<<sum<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | misosoup |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 993 Byte |
Status | AC |
Exec Time | 527 ms |
Memory | 23680 KB |
Judge Result
Set Name | sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample01.txt, sample02.txt |
All | 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt, sample01.txt, sample02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00.txt | AC | 343 ms | 23680 KB |
01.txt | AC | 361 ms | 23552 KB |
02.txt | AC | 260 ms | 23680 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 2 ms | 256 KB |
07.txt | AC | 2 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 2 ms | 256 KB |
11.txt | AC | 516 ms | 23680 KB |
12.txt | AC | 524 ms | 23680 KB |
13.txt | AC | 521 ms | 23680 KB |
14.txt | AC | 522 ms | 23680 KB |
15.txt | AC | 460 ms | 23680 KB |
16.txt | AC | 527 ms | 23680 KB |
17.txt | AC | 515 ms | 23680 KB |
18.txt | AC | 266 ms | 23680 KB |
19.txt | AC | 201 ms | 23680 KB |
sample01.txt | AC | 1 ms | 256 KB |
sample02.txt | AC | 1 ms | 256 KB |