結果
問題 |
No.1588 Connection
|
ユーザー |
![]() |
提出日時 | 2021-07-24 09:25:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 234 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 96,096 KB |
平均クエリ数 | 343.94 |
最終ジャッジ日時 | 2024-07-19 09:17:28 |
合計ジャッジ時間 | 5,475 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
ソースコード
import sys sys.setrecursionlimit(2000) N,M = map(int,input().split()) S0 = [[1] * (N+2)] S = S0 + [([1] + [0] * N + [1]) for _ in range(N)] + S0 D = [[0,1],[1,0],[0,-1],[-1,0]] def dfs(x,y): if x == N and y == N: print("Yes") sys.exit() for d in D: a,b = d x1 = x + a y1 = y + b if S[x1][y1] == 0: S[x1][y1] = 1 print(x1,y1) res = input() if res == "-1": sys.exit() elif res == "Black": dfs(x1,y1) S[1][1] = 1 dfs(1,1) print("No") sys.exit()