結果
問題 | No.1588 Connection |
ユーザー | norioc |
提出日時 | 2021-07-09 01:28:25 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
QLE
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 404 ms |
コンパイル使用メモリ | 10,788 KB |
実行使用メモリ | 25,300 KB |
平均クエリ数 | 1970.81 |
最終ジャッジ日時 | 2023-09-24 11:56:37 |
合計ジャッジ時間 | 6,255 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
24,344 KB |
testcase_01 | AC | 44 ms
24,500 KB |
testcase_02 | AC | 44 ms
24,380 KB |
testcase_03 | AC | 43 ms
24,240 KB |
testcase_04 | QLE | - |
testcase_05 | QLE | - |
testcase_06 | QLE | - |
testcase_07 | AC | 44 ms
24,092 KB |
testcase_08 | QLE | - |
testcase_09 | QLE | - |
testcase_10 | QLE | - |
testcase_11 | QLE | - |
testcase_12 | QLE | - |
testcase_13 | QLE | - |
testcase_14 | QLE | - |
testcase_15 | QLE | - |
testcase_16 | AC | 44 ms
24,708 KB |
testcase_17 | AC | 45 ms
24,600 KB |
testcase_18 | AC | 44 ms
24,264 KB |
testcase_19 | AC | 45 ms
23,916 KB |
testcase_20 | AC | 46 ms
24,028 KB |
testcase_21 | QLE | - |
testcase_22 | QLE | - |
testcase_23 | QLE | - |
testcase_24 | QLE | - |
testcase_25 | QLE | - |
testcase_26 | QLE | - |
testcase_27 | QLE | - |
testcase_28 | QLE | - |
testcase_29 | QLE | - |
testcase_30 | QLE | - |
testcase_31 | AC | 44 ms
23,916 KB |
ソースコード
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) while len(q) > 0: r, c = q.popleft() if used[r, c]: continue if r == N and c == N: return True black = query(r, c) 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')