結果

問題 No.1588 Connection
ユーザー H3PO4H3PO4
提出日時 2021-07-08 23:25:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 26,840 KB
平均クエリ数 559.75
最終ジャッジ日時 2023-09-24 11:39:02
合計ジャッジ時間 4,295 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
24,200 KB
testcase_01 AC 43 ms
24,636 KB
testcase_02 AC 43 ms
24,784 KB
testcase_03 AC 43 ms
24,904 KB
testcase_04 AC 45 ms
24,672 KB
testcase_05 AC 45 ms
24,048 KB
testcase_06 AC 45 ms
24,248 KB
testcase_07 AC 43 ms
24,620 KB
testcase_08 AC 46 ms
24,156 KB
testcase_09 AC 46 ms
24,480 KB
testcase_10 AC 47 ms
24,364 KB
testcase_11 AC 47 ms
24,852 KB
testcase_12 AC 87 ms
24,068 KB
testcase_13 AC 93 ms
24,392 KB
testcase_14 AC 43 ms
24,616 KB
testcase_15 AC 45 ms
24,544 KB
testcase_16 AC 43 ms
24,396 KB
testcase_17 AC 44 ms
24,664 KB
testcase_18 AC 44 ms
24,692 KB
testcase_19 AC 46 ms
24,716 KB
testcase_20 AC 50 ms
26,628 KB
testcase_21 AC 153 ms
26,404 KB
testcase_22 AC 154 ms
26,680 KB
testcase_23 AC 86 ms
24,564 KB
testcase_24 AC 66 ms
24,544 KB
testcase_25 AC 103 ms
26,840 KB
testcase_26 AC 103 ms
26,152 KB
testcase_27 AC 66 ms
24,572 KB
testcase_28 AC 60 ms
24,740 KB
testcase_29 AC 156 ms
24,236 KB
testcase_30 AC 156 ms
24,180 KB
testcase_31 AC 43 ms
24,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, M = map(int, input().split())
d = deque([(0, 0)])
table = [[None] * N for _ in range(N)]
table[0][0] = True


def query(x, y):
    print(x, y, flush=True)
    T = input()
    if T == 'Black':
        return True
    elif T == 'White':
        return False
    else:
        raise ValueError


while d:
    x, y = d.pop()
    if x == N - 1 and y == N - 1:
        print('Yes', flush=True)
        exit()
    for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        xdx, ydy = x + dx, y + dy
        if 0 <= xdx < N and 0 <= ydy < N and table[xdx][ydy] is None:
            T = query(xdx + 1, ydy + 1)
            table[xdx][ydy] = T
            if T:
                d.append((xdx, ydy))
print('No', flush=True)
0