結果

問題 No.1588 Connection
ユーザー noriocnorioc
提出日時 2021-07-09 01:30:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 768 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 25,360 KB
平均クエリ数 1970.81
最終ジャッジ日時 2023-09-24 11:56:48
合計ジャッジ時間 6,087 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
24,328 KB
testcase_01 AC 43 ms
24,692 KB
testcase_02 AC 43 ms
24,372 KB
testcase_03 AC 44 ms
24,684 KB
testcase_04 AC 170 ms
24,232 KB
testcase_05 AC 166 ms
24,744 KB
testcase_06 AC 169 ms
24,416 KB
testcase_07 AC 44 ms
24,544 KB
testcase_08 AC 168 ms
24,508 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 168 ms
24,520 KB
testcase_15 AC 171 ms
24,588 KB
testcase_16 AC 44 ms
24,276 KB
testcase_17 AC 44 ms
24,048 KB
testcase_18 AC 43 ms
24,708 KB
testcase_19 AC 44 ms
24,844 KB
testcase_20 AC 45 ms
24,104 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 169 ms
24,744 KB
testcase_26 AC 172 ms
24,644 KB
testcase_27 AC 168 ms
24,844 KB
testcase_28 AC 169 ms
24,788 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 44 ms
24,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

N, M = map(int, input().split())

def query(r, c) -> bool:
    print(r, c)
    res = input()
    if res == '-1': exit()
    return res == 'Black'

def calc():
    q = collections.deque()
    q.append((1, 1))
    used = collections.defaultdict(bool)
    m = 0

    while len(q) > 0:
        r, c = q.popleft()
        if used[r, c]: continue
        if r == N and c == N: return True

        if m == 3000: return False
        black = query(r, c)
        m += 1

        if not black: continue
        for dr, dc in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            if not (1 <= r + dr <= N): continue
            if not (1 <= c + dc <= N): continue
            q.append((r + dr, c + dc))

ans = calc()
if ans:
    print('Yes')
else:
    print('No')
0