Submission #1454714
Source Code Expand
#include<iostream> #include<algorithm> using namespace std; long long a[1010][1010],dp[1010][1010],h,w; long long DFS(int y,int x){ if(dp[y][x]>0)return dp[y][x]; int dx[]={0,1,0,-1},dy[]={1,0,-1,0},cnt=1; for(int i=0;i<4;i++){ int xx=x+dx[i],yy=y+dy[i]; if(xx>=0&&xx<w&&yy>=0&&yy<h){ if(a[y][x]<a[yy][xx]){ cnt+=DFS(yy,xx); } } } dp[y][x]=cnt; return cnt; } int main(){ cin>>h>>w; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>a[i][j]; dp[i][j]=0; } } long long ans=0; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ ans+=DFS(i,j); } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | ynymxiaolongbao |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 651 Byte |
Status | WA |
Exec Time | 2104 ms |
Memory | 16384 KB |
Judge Result
Set Name | sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 1228 ms | 16384 KB |
01.txt | TLE | 2104 ms | 16256 KB |
02.txt | AC | 170 ms | 16128 KB |
03.txt | AC | 2 ms | 2304 KB |
04.txt | AC | 2 ms | 2304 KB |
05.txt | AC | 2 ms | 2304 KB |
06.txt | AC | 2 ms | 2304 KB |
07.txt | AC | 2 ms | 2304 KB |
08.txt | AC | 2 ms | 2432 KB |
09.txt | AC | 2 ms | 2304 KB |
10.txt | AC | 3 ms | 4608 KB |
11.txt | AC | 427 ms | 16128 KB |
12.txt | AC | 431 ms | 16128 KB |
13.txt | AC | 423 ms | 16128 KB |
14.txt | AC | 424 ms | 16128 KB |
15.txt | WA | 981 ms | 16384 KB |
16.txt | AC | 423 ms | 16128 KB |
17.txt | AC | 432 ms | 16128 KB |
18.txt | AC | 181 ms | 16128 KB |
19.txt | AC | 172 ms | 16128 KB |
sample01.txt | AC | 2 ms | 2304 KB |
sample02.txt | AC | 2 ms | 2304 KB |