Submission #1178033


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
    c = [[1]*w for _ in range(h)]
    q = [(a[i][j],i,j) for j in range(w) for i in range(h)]
    q.sort()
    dy = [0,0,1,-1]
    dx = [1,-1,0,0]
    for qi in range(h*w):
        k, y, x = q[qi]
        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
            c[ty][tx] += c[y][x]

    return sum([sum(r) % mod for r in c]) % mod

print(main())

Submission Info

Submission Time
Task D - 経路
User iehn
Language Python (3.4.3)
Score 0
Code Size 968 Byte
Status TLE
Exec Time 2130 ms
Memory 415024 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 12
TLE × 12
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 2118 ms 219724 KB
01.txt TLE 2130 ms 415024 KB
02.txt TLE 2112 ms 128580 KB
03.txt AC 40 ms 5412 KB
04.txt AC 40 ms 5412 KB
05.txt AC 40 ms 5404 KB
06.txt AC 42 ms 5532 KB
07.txt AC 43 ms 5536 KB
08.txt AC 41 ms 5408 KB
09.txt AC 40 ms 5412 KB
10.txt AC 47 ms 5664 KB
11.txt TLE 2114 ms 161152 KB
12.txt TLE 2114 ms 161156 KB
13.txt TLE 2113 ms 160592 KB
14.txt TLE 2114 ms 160644 KB
15.txt TLE 2117 ms 197396 KB
16.txt TLE 2115 ms 160388 KB
17.txt TLE 2117 ms 161156 KB
18.txt TLE 2112 ms 129420 KB
19.txt TLE 2112 ms 128624 KB
sample01.txt AC 40 ms 5404 KB
sample02.txt AC 40 ms 5404 KB