結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-12-08 19:10:12 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 2,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 117 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 29,528 KB |
| 平均クエリ数 | 557.78 |
| 最終ジャッジ日時 | 2024-07-16 08:08:12 |
| 合計ジャッジ時間 | 4,457 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
import sys
N,M = map(int,input().split())
B = 'Black'
W = 'White'
q = []
masu = [[0] * (N+1) for _ in range(N+1)]
masu[1][1] = 1
q.append((1,1))
while len(q):
x,y = q.pop()
if x == N and y == N:
print('Yes')
exit()
for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
if 1 <= x+i <= N and 1 <= y+j <= N:
if masu[x+i][y+j] == 0:
print(x+i,y+j)
T = input()
if T == B:
masu[x+i][y+j] = 1
q.append((x+i,y+j))
else:
masu[x+i][y+j] = -1
print('No')