Submission #1178106


Source Code Expand

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


def main():
    h,w = LI()
    a = [LI() for _ in range(h)]
    r = 0
    dy = [0,0,1,-1]
    dx = [1,-1,0,0]

    m = [[None]*w for _ in range(h)]
    def f(y,x):
        if m[y][x]:
            return m[y][x]

        r = 1
        k = a[y][x]
        for i in range(4):
            ty,tx = y+dy[i], x+dx[i]
            if 0 <= ty < h and 0 <= tx < w:
                if a[ty][tx] >= k:
                    continue
                r += f(ty,tx)
        m[y][x] = r
        return r

    rr = 0
    for i in range(h):
        for j in range(w):
            rr += f(i,j)
            rr %= mod
    return rr


print(main())

Submission Info

Submission Time
Task D - 経路
User iehn
Language PyPy3 (2.4.0)
Score 0
Code Size 1053 Byte
Status TLE
Exec Time 2121 ms
Memory 264688 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 23
TLE × 1
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 AC 1846 ms 225636 KB
01.txt TLE 2121 ms 264688 KB
02.txt AC 800 ms 101080 KB
03.txt AC 283 ms 64236 KB
04.txt AC 296 ms 64236 KB
05.txt AC 295 ms 64236 KB
06.txt AC 315 ms 65644 KB
07.txt AC 331 ms 67436 KB
08.txt AC 326 ms 67816 KB
09.txt AC 295 ms 64236 KB
10.txt AC 369 ms 70996 KB
11.txt AC 1370 ms 120536 KB
12.txt AC 1430 ms 120536 KB
13.txt AC 1378 ms 120152 KB
14.txt AC 1356 ms 120408 KB
15.txt AC 1981 ms 209644 KB
16.txt AC 1385 ms 121176 KB
17.txt AC 1403 ms 120280 KB
18.txt AC 851 ms 99928 KB
19.txt AC 711 ms 87384 KB
sample01.txt AC 287 ms 64236 KB
sample02.txt AC 303 ms 64236 KB