Submission #3445283


Source Code Expand

P=10**9+7
H,W=map(int,input().split())
a=[list(map(int,input().split())) for i in range(H)]
dp=[[0 for i in range(W)] for j in range(H)]
used=[[False for i in range(W)] for i in range(H)]
def f(x,y):
    if used[x][y]:
        return dp[x][y]
    dx=[0,0,-1,1]
    dy=[1,-1,0,0]
    result=1
    for k in range(4):
        nx=x+dx[k]
        ny=y+dy[k]
        if (0<=nx<H and 0<=ny<W):
            if (a[nx][ny]>a[x][y]):
                result=(result+f(nx,ny))%P
    used[x][y]=True
    dp[x][y]=result
    return result
ans=0
for i in range(H):
    for j in range(W):
        ans=(ans+f(i,j))%P
print(ans)

Submission Info

Submission Time
Task D - 経路
User shakayami
Language PyPy3 (2.4.0)
Score 0
Code Size 635 Byte
Status RE
Exec Time 1396 ms
Memory 146316 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 22
RE × 2
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 RE 583 ms 78428 KB
01.txt RE 598 ms 75868 KB
02.txt AC 734 ms 77660 KB
03.txt AC 162 ms 38256 KB
04.txt AC 160 ms 38256 KB
05.txt AC 162 ms 38256 KB
06.txt AC 185 ms 40176 KB
07.txt AC 198 ms 41584 KB
08.txt AC 181 ms 40176 KB
09.txt AC 162 ms 38256 KB
10.txt AC 214 ms 42988 KB
11.txt AC 1161 ms 96732 KB
12.txt AC 1214 ms 97756 KB
13.txt AC 1155 ms 96220 KB
14.txt AC 1171 ms 95708 KB
15.txt AC 1396 ms 146316 KB
16.txt AC 1150 ms 96732 KB
17.txt AC 1218 ms 98140 KB
18.txt AC 749 ms 76764 KB
19.txt AC 607 ms 72796 KB
sample01.txt AC 162 ms 38256 KB
sample02.txt AC 164 ms 38256 KB