Submission #2532187
Source Code Expand
import java.util.Scanner; public class Main { static final int[] dx = { 1, 0, -1, 0 }; static final int[] dy = { 0, 1, 0, -1 }; static final int MOD = 1000000007; static int h, w; static int[][] a, memo; public static void main(String[] args) { Scanner sc = new Scanner(System.in); h = sc.nextInt(); w = sc.nextInt(); a = new int[h + 2][w + 2]; for (int y = 1; y <= h; y++) { for (int x = 1; x <= w; x++) { a[y][x] = sc.nextInt(); } } int sum = 0; memo = new int[h + 2][w + 2]; for (int y = 1; y <= h; y++) { for (int x = 1; x <= w; x++) { sum += dp(y, x); sum %= MOD; } } System.out.println(sum); } static int dp(int y, int x) { if (memo[y][x] > 0) return memo[y][x]; int result = 1; for (int i = 0; i < 4; i++) { int ny = y + dy[i]; int nx = x + dx[i]; if (a[y][x] < a[ny][nx]) result = (result + dp(ny, nx)) % MOD; } return memo[y][x] = result; } }
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | deka0106 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 984 Byte |
Status | MLE |
Exec Time | 1236 ms |
Memory | 282516 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 | MLE | 1017 ms | 247608 KB |
01.txt | MLE | 1077 ms | 257736 KB |
02.txt | AC | 934 ms | 241624 KB |
03.txt | AC | 92 ms | 18772 KB |
04.txt | AC | 94 ms | 19412 KB |
05.txt | AC | 110 ms | 20564 KB |
06.txt | AC | 122 ms | 21972 KB |
07.txt | AC | 131 ms | 23428 KB |
08.txt | AC | 120 ms | 19796 KB |
09.txt | AC | 94 ms | 19668 KB |
10.txt | AC | 149 ms | 22992 KB |
11.txt | MLE | 1228 ms | 274656 KB |
12.txt | MLE | 1204 ms | 280196 KB |
13.txt | MLE | 1236 ms | 282516 KB |
14.txt | MLE | 1219 ms | 281408 KB |
15.txt | MLE | 1164 ms | 267940 KB |
16.txt | MLE | 1232 ms | 282196 KB |
17.txt | MLE | 1203 ms | 278928 KB |
18.txt | AC | 943 ms | 242208 KB |
19.txt | AC | 856 ms | 234340 KB |
sample01.txt | AC | 93 ms | 19156 KB |
sample02.txt | AC | 93 ms | 18644 KB |