結果

問題 No.1588 Connection
ユーザー shinichishinichi
提出日時 2021-07-08 23:14:43
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 970 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 97,744 KB
平均クエリ数 842.41
最終ジャッジ日時 2023-09-24 11:34:49
合計ジャッジ時間 7,850 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
87,004 KB
testcase_01 WA -
testcase_02 AC 110 ms
87,244 KB
testcase_03 AC 112 ms
87,044 KB
testcase_04 AC 109 ms
86,992 KB
testcase_05 AC 109 ms
86,632 KB
testcase_06 AC 114 ms
87,456 KB
testcase_07 AC 113 ms
87,120 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 110 ms
87,320 KB
testcase_15 AC 109 ms
87,724 KB
testcase_16 AC 108 ms
87,372 KB
testcase_17 AC 108 ms
87,568 KB
testcase_18 AC 107 ms
87,100 KB
testcase_19 AC 108 ms
87,008 KB
testcase_20 AC 116 ms
88,532 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 123 ms
89,044 KB
testcase_26 AC 239 ms
95,840 KB
testcase_27 AC 117 ms
87,232 KB
testcase_28 RE -
testcase_29 RE -
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[nx][ny] 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