結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2025-11-14 16:51:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 256 ms / 2,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 249 ms |
| コンパイル使用メモリ | 82,256 KB |
| 実行使用メモリ | 97,544 KB |
| 平均クエリ数 | 551.31 |
| 最終ジャッジ日時 | 2025-11-14 16:51:55 |
| 合計ジャッジ時間 | 5,786 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
from collections import deque
N,M = list(map(int,input().split()))
dy = [-1,1,0,0]
dx = [0,0,-1,1]
q = deque([(0,0)])
grid = [[-1 for _ in range(N)] for _ in range(N)]
while(q):
y,x = q.popleft()
if(y == N-1 and x == N-1):
print("Yes")
exit()
if(grid[y][x] != -1):continue
if not (y == 0 and x == 0):
print(y+1,x+1)
bw = input()
grid[y][x] = 1 if bw == "Black" else 0
if(bw == "White"):continue
for i in range(4):
next_y = y + dy[i]
next_x = x + dx[i]
if(next_y < 0 or N <= next_y):continue
if(next_x < 0 or N <= next_x):continue
if(grid[next_y][next_x] == 0):continue
q.append((next_y,next_x))
print("No")
回転