結果

問題 No.1588 Connection
ユーザー H3PO4H3PO4
提出日時 2021-07-08 23:25:26
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 58 ms
使用メモリ 24,764 KB
平均クエリ数 559.75
最終ジャッジ日時 2023-02-15 01:12:43
合計ジャッジ時間 3,838 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 35 ms
22,592 KB
testcase_01 AC 36 ms
22,580 KB
testcase_02 AC 36 ms
22,648 KB
testcase_03 AC 34 ms
22,468 KB
testcase_04 AC 35 ms
23,100 KB
testcase_05 AC 34 ms
22,744 KB
testcase_06 AC 36 ms
22,712 KB
testcase_07 AC 34 ms
22,628 KB
testcase_08 AC 37 ms
22,928 KB
testcase_09 AC 37 ms
22,536 KB
testcase_10 AC 37 ms
22,660 KB
testcase_11 AC 38 ms
23,060 KB
testcase_12 AC 76 ms
23,108 KB
testcase_13 AC 83 ms
22,412 KB
testcase_14 AC 35 ms
22,656 KB
testcase_15 AC 37 ms
22,840 KB
testcase_16 AC 35 ms
22,752 KB
testcase_17 AC 37 ms
23,096 KB
testcase_18 AC 35 ms
22,716 KB
testcase_19 AC 37 ms
23,008 KB
testcase_20 AC 42 ms
24,764 KB
testcase_21 AC 146 ms
24,748 KB
testcase_22 AC 146 ms
24,760 KB
testcase_23 AC 78 ms
22,944 KB
testcase_24 AC 57 ms
23,104 KB
testcase_25 AC 95 ms
24,656 KB
testcase_26 AC 91 ms
24,716 KB
testcase_27 AC 58 ms
23,420 KB
testcase_28 AC 51 ms
23,056 KB
testcase_29 AC 144 ms
22,736 KB
testcase_30 AC 146 ms
22,600 KB
testcase_31 AC 36 ms
22,968 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