結果

問題 No.1588 Connection
ユーザー shinichishinichi
提出日時 2021-07-08 23:19:03
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 970 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 96,652 KB
平均クエリ数 562.12
最終ジャッジ日時 2023-09-24 11:36:39
合計ジャッジ時間 6,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
87,120 KB
testcase_01 WA -
testcase_02 AC 115 ms
87,260 KB
testcase_03 AC 110 ms
87,472 KB
testcase_04 AC 111 ms
87,136 KB
testcase_05 AC 115 ms
87,208 KB
testcase_06 AC 114 ms
87,764 KB
testcase_07 AC 112 ms
87,740 KB
testcase_08 AC 117 ms
87,236 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 110 ms
87,044 KB
testcase_15 AC 111 ms
87,536 KB
testcase_16 AC 112 ms
87,236 KB
testcase_17 AC 112 ms
87,252 KB
testcase_18 AC 111 ms
87,324 KB
testcase_19 AC 115 ms
87,740 KB
testcase_20 AC 121 ms
88,728 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 210 ms
95,220 KB
testcase_26 AC 206 ms
94,708 KB
testcase_27 AC 154 ms
91,700 KB
testcase_28 AC 140 ms
92,308 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, M = map(int, input().split())
grid = [[None]*N for _ in range(N)]
grid[0][0] = True
grid[-1][-1] = True
M -= 2

q = deque()
q.append((0, 0))
move = [(-1, 0), (1, 0), (0, 1), (0, -1)]

def ques(y, x):
    print(x+1, y+1)
    s = input()
    if s == 'Black':
        return True
    else:
        return False


flag = False
qs = 0
while q and M:
    y, x = q.popleft()
    for dy, dx in move:
        ny, nx = dy+y, dx+x
        if 0 <= ny < N and 0 <= nx < N and grid[ny][nx] is None:
            if nx == ny == N-1:
                flag = True
                q = deque()
                break
            if ques(ny, nx):
                grid[ny][nx] = True
                q.append((ny, nx))
                qs += 1
                if qs == 3000:
                    q = deque()
                    break
                M -= 1
            else:
                grid[ny][nx] = False


if flag:
    print('Yes')
else:
    print('No')
0