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

Submission #420842

Source Code Expand

Copy
```def search(route, x, y):
if ((x < 0) | (w <= x) | (y < 0) | (h <= y)):
return

nextPoint = c[y][x]
if nextPoint == "g":
print "Yes"
exit()
elif ((nextPoint == ".") | (nextPoint == "s")):
route += 1
if(route < step[y][x]):
step[y][x] = route
search(route, x - 1, y)
search(route, x + 1, y)
search(route, x, y - 1)
search(route, x, y + 1)
return

global h
global w
global c
global step

h, w = map(int, raw_input().split())
c = []
step = [[30000 for _ in xrange(0,w)] for __ in range(0,h)]
for i in xrange(0, h):
c.append(list(raw_input()))

for i, math in enumerate(c):
if("s" in math):
search(-1, math.index("s"), i)

print "No"```

#### Submission Info

Submission Time 2015-06-06 21:55:47+0900 A - 深さ優先探索 mint149 Python (2.7.3) 0 695 Byte RE 1659 ms 13404 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
 AC × 5
 AC × 69 RE × 14
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt
All 00_min_01.txt, 00_min_02.txt, 00_min_03.txt, 00_min_04.txt, 00_min_05.txt, 00_min_06.txt, 00_min_07.txt, 00_min_08.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_rndhard_00.txt, 02_rndhard_01.txt, 02_rndhard_02.txt, 02_rndhard_03.txt, 02_rndhard_04.txt, 02_rndhard_05.txt, 02_rndhard_06.txt, 02_rndhard_07.txt, 02_rndhard_08.txt, 02_rndhard_09.txt, 02_rndhard_10.txt, 02_rndhard_11.txt, 02_rndhard_12.txt, 02_rndhard_13.txt, 02_rndhard_14.txt, 02_rndhard_15.txt, 02_rndhard_16.txt, 02_rndhard_17.txt, 02_rndhard_18.txt, 02_rndhard_19.txt, 02_rndhard_20.txt, 02_rndhard_21.txt, 02_rndhard_22.txt, 02_rndhard_23.txt, 02_rndhard_24.txt, 02_rndhard_25.txt, 02_rndhard_26.txt, 02_rndhard_27.txt, 02_rndhard_28.txt, 02_rndhard_29.txt, 02_rndhard_30.txt, 02_rndhard_31.txt, 02_rndhard_32.txt, 02_rndhard_33.txt, 02_rndhard_34.txt, 02_rndhard_35.txt, 02_rndhard_36.txt, 02_rndhard_37.txt, 02_rndhard_38.txt, 02_rndhard_39.txt, 03_rndhardsmall_00.txt, 03_rndhardsmall_01.txt, 03_rndhardsmall_02.txt, 03_rndhardsmall_03.txt, 03_rndhardsmall_04.txt, 03_rndhardsmall_05.txt, 03_rndhardsmall_06.txt, 03_rndhardsmall_07.txt, 03_rndhardsmall_08.txt, 03_rndhardsmall_09.txt
Case Name Status Exec Time Memory
00_min_01.txt 70 ms 3284 KB
00_min_02.txt 56 ms 3500 KB
00_min_03.txt 56 ms 3504 KB
00_min_04.txt 56 ms 3504 KB
00_min_05.txt 55 ms 3492 KB
00_min_06.txt 56 ms 3504 KB
00_min_07.txt 58 ms 3504 KB
00_min_08.txt 57 ms 3500 KB
00_sample_01.txt 56 ms 3304 KB
00_sample_02.txt 56 ms 3500 KB
00_sample_03.txt 56 ms 3504 KB
00_sample_04.txt 56 ms 3500 KB
00_sample_05.txt 56 ms 3500 KB
01_rnd_00.txt 102 ms 7724 KB
01_rnd_01.txt 217 ms 13392 KB
01_rnd_02.txt 234 ms 13392 KB
01_rnd_03.txt 218 ms 13280 KB
01_rnd_04.txt 217 ms 13380 KB
01_rnd_05.txt 106 ms 7728 KB
01_rnd_06.txt 222 ms 13392 KB
01_rnd_07.txt 218 ms 13396 KB
01_rnd_08.txt 105 ms 7716 KB
01_rnd_09.txt 107 ms 7668 KB
01_rnd_10.txt 455 ms 13340 KB
01_rnd_11.txt 105 ms 7656 KB
01_rnd_12.txt 217 ms 13380 KB
01_rnd_13.txt 221 ms 13288 KB
01_rnd_14.txt 104 ms 7660 KB
01_rnd_15.txt 241 ms 13392 KB
01_rnd_16.txt 104 ms 7720 KB
01_rnd_17.txt 223 ms 13404 KB
01_rnd_18.txt 106 ms 7716 KB
01_rnd_19.txt 223 ms 13380 KB
02_rndhard_00.txt 165 ms 7848 KB
02_rndhard_01.txt 165 ms 7844 KB
02_rndhard_02.txt 245 ms 13404 KB
02_rndhard_03.txt 244 ms 13304 KB
02_rndhard_04.txt 107 ms 7652 KB
02_rndhard_05.txt 110 ms 7656 KB
02_rndhard_06.txt 170 ms 7832 KB
02_rndhard_07.txt 107 ms 7716 KB
02_rndhard_08.txt 1058 ms 8108 KB
02_rndhard_09.txt 1045 ms 8100 KB
02_rndhard_10.txt 1249 ms 8040 KB
02_rndhard_11.txt 1257 ms 8040 KB
02_rndhard_12.txt 665 ms 7912 KB
02_rndhard_13.txt 668 ms 7912 KB
02_rndhard_14.txt 1284 ms 8100 KB
02_rndhard_15.txt 1283 ms 8040 KB
02_rndhard_16.txt 129 ms 7732 KB
02_rndhard_17.txt 129 ms 7724 KB
02_rndhard_18.txt 161 ms 7844 KB
02_rndhard_19.txt 154 ms 7652 KB
02_rndhard_20.txt 195 ms 7856 KB
02_rndhard_21.txt 196 ms 7856 KB
02_rndhard_22.txt 1659 ms 8236 KB
02_rndhard_23.txt 879 ms 8108 KB
02_rndhard_24.txt 135 ms 7848 KB
02_rndhard_25.txt 136 ms 7852 KB
02_rndhard_26.txt 159 ms 7856 KB
02_rndhard_27.txt 107 ms 7724 KB
02_rndhard_28.txt 208 ms 7852 KB
02_rndhard_29.txt 215 ms 7788 KB
02_rndhard_30.txt 104 ms 7716 KB
02_rndhard_31.txt 104 ms 7728 KB
02_rndhard_32.txt 858 ms 7980 KB
02_rndhard_33.txt 758 ms 7972 KB
02_rndhard_34.txt 133 ms 7844 KB
02_rndhard_35.txt 133 ms 7656 KB
02_rndhard_36.txt 125 ms 7656 KB
02_rndhard_37.txt 124 ms 7844 KB
02_rndhard_38.txt 218 ms 7852 KB
02_rndhard_39.txt 219 ms 7844 KB
03_rndhardsmall_00.txt 57 ms 3500 KB
03_rndhardsmall_01.txt 56 ms 3496 KB
03_rndhardsmall_02.txt 56 ms 3492 KB
03_rndhardsmall_03.txt 57 ms 3496 KB
03_rndhardsmall_04.txt 56 ms 3304 KB
03_rndhardsmall_05.txt 56 ms 3304 KB
03_rndhardsmall_06.txt 56 ms 3304 KB
03_rndhardsmall_07.txt 57 ms 3492 KB
03_rndhardsmall_08.txt 56 ms 3492 KB
03_rndhardsmall_09.txt 57 ms 3496 KB