結果
問題 | No.2412 YOU Grow Bigger! |
ユーザー | flygon |
提出日時 | 2023-08-11 23:42:27 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,552 bytes |
コンパイル時間 | 456 ms |
コンパイル使用メモリ | 82,124 KB |
実行使用メモリ | 78,244 KB |
最終ジャッジ日時 | 2024-11-18 19:24:13 |
合計ジャッジ時間 | 4,572 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
55,848 KB |
testcase_01 | AC | 43 ms
56,416 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 69 ms
73,664 KB |
testcase_10 | AC | 101 ms
77,264 KB |
testcase_11 | AC | 57 ms
67,208 KB |
testcase_12 | AC | 48 ms
62,136 KB |
testcase_13 | AC | 125 ms
78,092 KB |
testcase_14 | AC | 69 ms
73,528 KB |
testcase_15 | AC | 53 ms
64,712 KB |
testcase_16 | AC | 63 ms
70,796 KB |
testcase_17 | AC | 65 ms
72,620 KB |
testcase_18 | AC | 136 ms
78,052 KB |
testcase_19 | AC | 51 ms
64,376 KB |
testcase_20 | AC | 62 ms
69,172 KB |
testcase_21 | AC | 107 ms
77,416 KB |
testcase_22 | AC | 130 ms
78,244 KB |
testcase_23 | AC | 119 ms
77,976 KB |
testcase_24 | AC | 138 ms
77,836 KB |
testcase_25 | WA | - |
testcase_26 | AC | 120 ms
78,048 KB |
testcase_27 | AC | 68 ms
71,704 KB |
testcase_28 | AC | 137 ms
77,976 KB |
testcase_29 | AC | 51 ms
64,536 KB |
testcase_30 | AC | 42 ms
55,788 KB |
ソースコード
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 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 dx in [1,0,-1]: for dy in [1,0,-1]: if dx == 0 and dy == 0: continue nx, ny = x+dx, y+dy 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: for i in range(h-2): for j in range(w-2): d1 = max(i,j) d2 = max(h-3-i, w-3-j) if d1 <= 1 or d2 <= 1: continue gg = [g[i][::1] for i in range(h-2)] for di in [-1,0,1]: for dj in [-1,0,1]: gg[i+di][j+dj] = 0 if bfs(0,0,gg)[-1][-1] == -1: print(1) exit() print(2)