ソースコード 拡げる

Copy
```def solve():
result = think(c)
write(result)

c = []
for y in range(h):
c.append(list(buf))
return c

if n == 0:
return input().rstrip()
else:
return input().rstrip()[:n]

def think(c):
w, h = get_area(c)

wall = '#'
start = 's'
goal = 'g'

sx, sy = find(c, start)
gx, gy = find(c, goal)

visited_area = [[0 for x in range(w)] for y in range(h)]

search(c, sx, sy, w, h, visited_area)

if visited_area[gy][gx] == 0:
return 'No'
else:
return 'Yes'

def search(c, x, y, w, h, visited_area):
if not (0 <= x < w and 0 <= y < h and c[y][x] != '#' and visited_area[y][x] == 0):
return
if visited_area[y][x] == 1:
return
visited_area[y][x] = 1
search(c, x + 1, y, w, h, visited_area)
search(c, x - 1, y, w, h, visited_area)
search(c, x, y + 1, w, h, visited_area)
search(c, x, y - 1, w, h, visited_area)

def get_area(c):
h = len(c)
w = len(c[0])
return w, h

def find(c, mark):
w, h = get_area(c)
for y in range(h):
for x in range(w):
if c[y][x] == mark:
return x, y

def write(result):
print(result)

if __name__ == '__main__':
import sys
sys.setrecursionlimit(300000)
solve()```

#### 提出情報

提出日時 2019-08-24 16:47:43+0900 A - 深さ優先探索 vineyoshi PyPy3 (2.4.0) 0 1552 Byte TLE 2166 ms 950020 KB

#### ジャッジ結果

セット名 Sample All

 AC × 5
 AC × 78 TLE × 5
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_min_01.txt 160 ms 38256 KB
00_min_02.txt 159 ms 38256 KB
00_min_03.txt 160 ms 38256 KB
00_min_04.txt 159 ms 38256 KB
00_min_05.txt 159 ms 38256 KB
00_min_06.txt 159 ms 38256 KB
00_min_07.txt 160 ms 38256 KB
00_min_08.txt 159 ms 38256 KB
00_sample_01.txt 159 ms 38256 KB
00_sample_02.txt 160 ms 38256 KB
00_sample_03.txt 159 ms 38256 KB
00_sample_04.txt 160 ms 38256 KB
00_sample_05.txt 160 ms 38256 KB
01_rnd_00.txt 203 ms 49776 KB
01_rnd_01.txt 2112 ms 151792 KB
01_rnd_02.txt 1309 ms 95724 KB
01_rnd_03.txt 2111 ms 130160 KB
01_rnd_04.txt 2095 ms 143984 KB
01_rnd_05.txt 202 ms 49776 KB
01_rnd_06.txt 1850 ms 83312 KB
01_rnd_07.txt 2166 ms 950020 KB
01_rnd_08.txt 203 ms 49776 KB
01_rnd_09.txt 206 ms 49776 KB
01_rnd_10.txt 705 ms 62064 KB
01_rnd_11.txt 204 ms 49776 KB
01_rnd_12.txt 1795 ms 127600 KB
01_rnd_13.txt 1768 ms 125552 KB
01_rnd_14.txt 208 ms 49776 KB
01_rnd_15.txt 1072 ms 74096 KB
01_rnd_16.txt 207 ms 49776 KB
01_rnd_17.txt 913 ms 66668 KB
01_rnd_18.txt 211 ms 49776 KB
01_rnd_19.txt 2116 ms 155632 KB
02_rndhard_00.txt 227 ms 52848 KB
02_rndhard_01.txt 223 ms 52848 KB
02_rndhard_02.txt 264 ms 56412 KB
02_rndhard_03.txt 253 ms 56284 KB
02_rndhard_04.txt 204 ms 49776 KB
02_rndhard_05.txt 205 ms 49776 KB
02_rndhard_06.txt 208 ms 51312 KB
02_rndhard_07.txt 206 ms 49776 KB
02_rndhard_08.txt 232 ms 53996 KB
02_rndhard_09.txt 232 ms 53996 KB
02_rndhard_10.txt 235 ms 54124 KB
02_rndhard_11.txt 236 ms 54124 KB
02_rndhard_12.txt 236 ms 54000 KB
02_rndhard_13.txt 235 ms 54000 KB
02_rndhard_14.txt 244 ms 55276 KB
02_rndhard_15.txt 247 ms 55340 KB
02_rndhard_16.txt 209 ms 51312 KB
02_rndhard_17.txt 210 ms 51312 KB
02_rndhard_18.txt 222 ms 52848 KB
02_rndhard_19.txt 220 ms 52848 KB
02_rndhard_20.txt 225 ms 52464 KB
02_rndhard_21.txt 224 ms 52464 KB
02_rndhard_22.txt 228 ms 52208 KB
02_rndhard_23.txt 225 ms 52208 KB
02_rndhard_24.txt 228 ms 53360 KB
02_rndhard_25.txt 227 ms 53360 KB
02_rndhard_26.txt 229 ms 53480 KB
02_rndhard_27.txt 204 ms 49776 KB
02_rndhard_28.txt 242 ms 54896 KB
02_rndhard_29.txt 232 ms 54896 KB
02_rndhard_30.txt 209 ms 49776 KB
02_rndhard_31.txt 205 ms 49776 KB
02_rndhard_32.txt 232 ms 55020 KB
02_rndhard_33.txt 230 ms 55020 KB
02_rndhard_34.txt 222 ms 51952 KB
02_rndhard_35.txt 215 ms 51952 KB
02_rndhard_36.txt 209 ms 51184 KB
02_rndhard_37.txt 208 ms 51184 KB
02_rndhard_38.txt 233 ms 57836 KB
02_rndhard_39.txt 232 ms 57836 KB
03_rndhardsmall_00.txt 164 ms 38256 KB
03_rndhardsmall_01.txt 165 ms 38384 KB
03_rndhardsmall_02.txt 164 ms 38256 KB
03_rndhardsmall_03.txt 165 ms 38384 KB
03_rndhardsmall_04.txt 164 ms 38256 KB
03_rndhardsmall_05.txt 167 ms 38256 KB
03_rndhardsmall_06.txt 164 ms 38256 KB
03_rndhardsmall_07.txt 165 ms 38256 KB
03_rndhardsmall_08.txt 165 ms 38256 KB
03_rndhardsmall_09.txt 165 ms 38256 KB