結果
問題 | No.1588 Connection |
ユーザー | tamato |
提出日時 | 2021-07-08 22:46:21 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,170 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 87,720 KB |
実行使用メモリ | 102,272 KB |
平均クエリ数 | 1045.69 |
最終ジャッジ日時 | 2023-09-24 10:48:41 |
合計ジャッジ時間 | 9,837 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 99 ms
88,100 KB |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 99 ms
87,796 KB |
testcase_10 | AC | 100 ms
88,060 KB |
testcase_11 | AC | 101 ms
87,540 KB |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 378 ms
96,436 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | AC | 237 ms
96,376 KB |
testcase_22 | AC | 248 ms
96,976 KB |
testcase_23 | AC | 167 ms
94,208 KB |
testcase_24 | WA | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | AC | 360 ms
96,752 KB |
testcase_28 | AC | 367 ms
96,052 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 102 ms
87,704 KB |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys from heapq import heappush, heappop input = sys.stdin.readline def ask(h, w): print(h, w) sys.stdout.flush() return input().rstrip('\n') N, M = map(int, input().split()) H = W = N Q = 3000 pq = [] heappush(pq, (N*2-3, 1)) heappush(pq, (N*2-3, W)) seen = [[0] * N for _ in range(N)] d = [(0, 1), (0, -1), (1, 0), (-1, 0)] M -= 2 while Q: _, hw = heappop(pq) h, w = divmod(hw, N) if seen[h][w]: continue T = ask(h+1, w+1) Q -= 1 if T == -1: exit() elif T == "Black": M -= 1 for dh, dw in d: h_new, w_new = h+dh, w+dw if 0 <= h_new < H and 0 <= w_new < W: if h_new == H-1 and w_new == W-1: print("Yes") exit() p = H-1 - h_new + W-1 - w_new if p - 1 <= M: heappush(pq, (H-1 - h_new + W-1 - w_new, h_new*W+w_new)) print("No") if __name__ == '__main__': main()