結果

問題 No.1588 Connection
ユーザー Igrmi
提出日時 2021-07-08 23:30:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 95,888 KB
平均クエリ数 372.84
最終ジャッジ日時 2024-07-17 12:35:22
合計ジャッジ時間 4,870 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
D = [(-1, 0), (1, 0), (0, -1), (0, 1)]
Grid = [[0] * (N + 1) for _ in range(N + 1)]
Grid[1][1] = 1
Query = [(1, 1)]
while Query:
    H, W = Query.pop()
    print(H, W)
    Judge = input()
    if Judge == 'Black':
        for d1, d2 in D:
            h, w = H + d1, W + d2
            if h == N and w == N:
                print('Yes')
                exit()
            if h >= 1 and h <= N and w >= 1 and w <= N and not Grid[h][w]:
                Query.append((h, w))
                Grid[h][w] = 1
    elif Judge == '-1': exit()
print('No')
0