結果
問題 | No.2412 YOU Grow Bigger! |
ユーザー | flygon |
提出日時 | 2023-08-11 23:28:57 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,327 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 77,568 KB |
最終ジャッジ日時 | 2024-11-18 18:58:29 |
合計ジャッジ時間 | 3,729 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
54,528 KB |
testcase_01 | AC | 48 ms
54,784 KB |
testcase_02 | AC | 48 ms
55,040 KB |
testcase_03 | AC | 79 ms
74,240 KB |
testcase_04 | AC | 84 ms
74,112 KB |
testcase_05 | AC | 94 ms
77,156 KB |
testcase_06 | AC | 98 ms
77,184 KB |
testcase_07 | AC | 89 ms
77,312 KB |
testcase_08 | AC | 100 ms
77,312 KB |
testcase_09 | AC | 69 ms
69,888 KB |
testcase_10 | WA | - |
testcase_11 | AC | 63 ms
65,024 KB |
testcase_12 | AC | 52 ms
60,928 KB |
testcase_13 | WA | - |
testcase_14 | AC | 65 ms
67,328 KB |
testcase_15 | AC | 58 ms
64,512 KB |
testcase_16 | AC | 64 ms
66,944 KB |
testcase_17 | AC | 66 ms
67,968 KB |
testcase_18 | WA | - |
testcase_19 | AC | 57 ms
63,616 KB |
testcase_20 | AC | 63 ms
66,560 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 83 ms
74,056 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 58 ms
64,384 KB |
testcase_30 | WA | - |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd h,w = map(int,input().split()) s = [input().rstrip() for i in range(h)] g = [[0]*(w-2) for i in range(h-2)] for i in range(1,h-1): for j in range(1, w-1): ok = 1 for dx in [0,-1,1]: for dy in [0,-1,1]: ok &= s[i+dx][j+dy] == "." g[i-1][j-1] = ok dx = [0,0,1,-1] dy = [1,-1,0,0] def bfs(x,y,g): que = deque([(x,y)]) depth = [[-1]*(w-2) for i in range(h-2)] depth[x][y] = 0 while que: x,y = que.popleft() for i in range(4): nx, ny = x+dx[i], y+dy[i] if not (0<= nx < h-2 and 0<=ny<w-2): continue if not g[nx][ny]: continue if depth[nx][ny] == -1: depth[nx][ny] = depth[x][y]+1 que.append((nx,ny)) return depth d = bfs(0,0,g) if d[-1][-1] == -1: print(0) else: gg = [g[i][::1] for i in range(h-2)] gg[0][1] = 0 if bfs(0,0,gg)[-1][-1] == -1: print(1) exit() gg = [g[i][::1] for i in range(h-2)] gg[1][0] = 0 if bfs(0,0,gg)[-1][-1] == -1: print(1) exit() print(2)