Submission #1178093


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 list(map(int, input().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
    ff = [[False]*w for _ in range(h)]
    dy = [0,0,1,-1]
    dx = [1,-1,0,0]

    m = {}
    def f(y,x):
        if (y,x) in m:
            return m[(y,x)]

        r = 1
        k = a[y][x]
        for i in range(4):
            ty,tx = y+dy[i], x+dx[i]
            if ty < 0 or ty >= h or tx < 0 or tx >= w:
                continue
            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 1082 Byte
Status TLE
Exec Time 2115 ms
Memory 225384 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 14
TLE × 10
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 TLE 2115 ms 207204 KB
01.txt TLE 2115 ms 225384 KB
02.txt TLE 2083 ms 162148 KB
03.txt AC 286 ms 64236 KB
04.txt AC 275 ms 64236 KB
05.txt AC 271 ms 64236 KB
06.txt AC 295 ms 65900 KB
07.txt AC 310 ms 67692 KB
08.txt AC 321 ms 67944 KB
09.txt AC 274 ms 64236 KB
10.txt AC 347 ms 71636 KB
11.txt TLE 2110 ms 167012 KB
12.txt TLE 2110 ms 145124 KB
13.txt TLE 2110 ms 168804 KB
14.txt TLE 2110 ms 168420 KB
15.txt TLE 2113 ms 185832 KB
16.txt TLE 2110 ms 167140 KB
17.txt TLE 2110 ms 141552 KB
18.txt AC 1917 ms 161132 KB
19.txt AC 1523 ms 157284 KB
sample01.txt AC 272 ms 64236 KB
sample02.txt AC 280 ms 64236 KB