Submission #1777601
Source Code Expand
#include<iostream> using namespace std; typedef long long ll; const ll MOD = 1000000007; int H, W; ll dp[1000][1000]; ll in[1000][1000]; const int vx[4] = { 0,-1,0,1 }; const int vy[4] = { 1,0,-1,0 }; ll f(int a, int b) { if (dp[a][b] != 0)return dp[a][b]; ll ans = 0; for (int i = 0; i < 4; i++) { int nx = a + vx[i], ny = b + vy[i]; if (nx < 0 || ny < 0 || nx >= H || ny >= W)continue; if (in[a][b] < in[nx][ny])ans += f(nx, ny); } return dp[a][b] = ans + 1; } int main() { cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> in[i][j]; } } ll ans = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { ans += f(i, j); ans %= MOD; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | Sen |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 799 Byte |
Status | WA |
Exec Time | 450 ms |
Memory | 109056 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 | 250 ms | 16000 KB |
01.txt | WA | 362 ms | 109056 KB |
02.txt | AC | 170 ms | 15872 KB |
03.txt | AC | 2 ms | 2304 KB |
04.txt | AC | 2 ms | 2304 KB |
05.txt | AC | 1 ms | 2304 KB |
06.txt | AC | 2 ms | 2304 KB |
07.txt | AC | 2 ms | 2304 KB |
08.txt | AC | 1 ms | 2432 KB |
09.txt | AC | 1 ms | 2304 KB |
10.txt | AC | 3 ms | 4608 KB |
11.txt | AC | 421 ms | 15872 KB |
12.txt | AC | 420 ms | 15872 KB |
13.txt | AC | 450 ms | 15872 KB |
14.txt | AC | 421 ms | 15872 KB |
15.txt | WA | 367 ms | 16000 KB |
16.txt | AC | 422 ms | 15872 KB |
17.txt | AC | 420 ms | 15872 KB |
18.txt | AC | 179 ms | 15872 KB |
19.txt | AC | 165 ms | 15872 KB |
sample01.txt | AC | 1 ms | 2304 KB |
sample02.txt | AC | 1 ms | 2304 KB |