Submission #3811729
Source Code Expand
#include <iostream> #include <cmath> #include <vector> #include <map> #include <stack> #include <queue> #include <set> #include <algorithm> #include <iomanip> #include <string.h> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() typedef long long lint; using namespace std; int main(){ int H,W; cin>>H>>W; vector<array<int,3> > v; int a[H][W]; lint dp[H][W]; REP(i,H)REP(j,W){ cin>>a[i][j]; array<int,3> e={a[i][j],i,j}; v.push_back(e); } sort(ALL(v)); reverse(ALL(v)); for(auto e:v){ int h,w; h=e[1];w=e[2]; dp[h][w]=1; if(h>0 and a[h-1][w]>a[h][w])dp[h][w]+=dp[h-1][w]; if(h<H-1 and a[h+1][w]>a[h][w])dp[h][w]+=dp[h+1][w]; if(w>0 and a[h][w-1]>a[h][w])dp[h][w]+=dp[h][w-1]; if(w<W-1 and a[h][w+1]>a[h][w])dp[h][w]+=dp[h][w+1]; } lint ans=0; REP(i,H)REP(j,W)ans+=dp[i][j]; cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | tsjmt |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 984 Byte |
Status | WA |
Exec Time | 592 ms |
Memory | 24296 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 | 411 ms | 23784 KB |
01.txt | WA | 441 ms | 23656 KB |
02.txt | AC | 333 ms | 24168 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 | 2 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 3 ms | 384 KB |
11.txt | AC | 586 ms | 23784 KB |
12.txt | AC | 585 ms | 24040 KB |
13.txt | AC | 592 ms | 24168 KB |
14.txt | AC | 591 ms | 24296 KB |
15.txt | WA | 551 ms | 23784 KB |
16.txt | AC | 590 ms | 23784 KB |
17.txt | AC | 587 ms | 23784 KB |
18.txt | AC | 353 ms | 23784 KB |
19.txt | AC | 286 ms | 23784 KB |
sample01.txt | AC | 1 ms | 256 KB |
sample02.txt | AC | 1 ms | 256 KB |