Contest Duration: - (local time) (90 minutes) Back to Home

Submission #172257

Source Code Expand

Copy
```# -*- coding: utf-8 -*-

def getNeighbors(prices, r, c, row, col):
if row == 0:
up = -1
else:
up = prices[row-1][col]
if row == r - 1:
bottom = -1
else:
bottom = prices[row+1][col]
if col == 0:
left = -1
else:
left = prices[row][col-1]
if col == c - 1:
right = -1
else:
right = prices[row][col+1]
return [right, up, left, bottom]

def searchMaxPrice(prices, r, c, row, col, d):
maxPrice = -1
if d == 1:
maxPrice = max(getNeighbors(prices, r, c, row, col))
else:
if row != 0:
maxPrice = searchMaxPrice(prices, r, c, row-1, col, d-1)
if row != r - 1:
maxPrice = searchMaxPrice(prices, r, c, row+1, col, d-1)
if col != 0:
maxPrice = searchMaxPrice(prices, r, c, row, col-1, d-1)
if col != c - 1:
maxPrice = searchMaxPrice(prices, r, c, row, col+1, d-1)
return maxPrice

if __name__ == "__main__":
r, c, d = map(int, raw_input().split(" "))
prices = []
for i in range(r):
currRow = map(int, raw_input().split(" "))
prices.append(currRow)
print searchMaxPrice(prices, r, c, 0, 0, d)
```

#### Submission Info

Submission Time 2014-05-17 22:24:04+0900 B - 謎の人物X neruca_neruca Python (2.7.3) 0 1257 Byte TLE 2034 ms 35228 KB

#### Judge Result

Score / Max Score 0 / 0 0 / 60 0 / 40
Status
 AC × 2 TLE × 1
 AC × 3 TLE × 15
 AC × 1 TLE × 24 RE × 5
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 54 ms 3508 KB
sample_02.txt TLE 2028 ms 3504 KB
sample_03.txt AC 47 ms 3504 KB
subtask1_01.txt AC 48 ms 3512 KB
subtask1_02.txt TLE 2029 ms 3556 KB
subtask1_03.txt TLE 2029 ms 3452 KB
subtask1_04.txt TLE 2033 ms 3708 KB
subtask1_05.txt TLE 2029 ms 3504 KB
subtask1_06.txt TLE 2028 ms 3508 KB
subtask1_07.txt TLE 2030 ms 3760 KB
subtask1_08.txt TLE 2029 ms 3628 KB
subtask1_09.txt TLE 2034 ms 3580 KB
subtask1_10.txt TLE 2029 ms 3760 KB
subtask1_11.txt TLE 2030 ms 3784 KB
subtask1_12.txt TLE 2030 ms 3868 KB
subtask1_13.txt TLE 2029 ms 3752 KB
subtask1_14.txt TLE 2033 ms 3708 KB
subtask1_15.txt TLE 2028 ms 3760 KB
subtask2_01.txt TLE 2029 ms 3632 KB
subtask2_02.txt TLE 2029 ms 3884 KB
subtask2_03.txt TLE 2030 ms 12456 KB
subtask2_04.txt TLE 2030 ms 3688 KB
subtask2_05.txt TLE 2029 ms 4660 KB
subtask2_06.txt RE 263 ms 13356 KB
subtask2_07.txt TLE 2031 ms 11832 KB
subtask2_08.txt TLE 2032 ms 34988 KB
subtask2_09.txt TLE 2033 ms 30256 KB
subtask2_10.txt RE 889 ms 34944 KB
subtask2_11.txt TLE 2032 ms 18632 KB
subtask2_12.txt TLE 2033 ms 29860 KB
subtask2_13.txt RE 887 ms 35212 KB
subtask2_14.txt RE 860 ms 35228 KB
subtask2_15.txt RE 855 ms 35212 KB