結果

問題 No.1588 Connection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-14 23:02:01
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 656 bytes
コンパイル時間 1,179 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 99,856 KB
平均クエリ数 1057.38
最終ジャッジ日時 2023-09-24 12:09:49
合計ジャッジ時間 10,080 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 122 ms
87,708 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 235 ms
94,124 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 282 ms
95,668 KB
testcase_22 AC 283 ms
96,068 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 276 ms
94,308 KB
testcase_30 AC 279 ms
94,432 KB
testcase_31 AC 120 ms
87,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

n,m = map(int,input().split())
count = 0
q = deque([(1,0),(0,1)])
black = [[-1]*n for i in range(n)]
black[0][0] = black[-1][-1] = 1

while q or count < 3000:
    x,y = q.popleft()
    print(x+1,y+1)
    sys.stdout.flush()
    if input() == "Black":
        black[x][y] = 1
        for dx,dy in ((0,1),(1,0),(0,-1),(-1,0)):
            nx = x+dx
            ny = y+dy
            if nx == ny == n-1:
                print("Yes")
                exit()
            if 0 <= nx < n and 0 <= ny < n and black[nx][ny] == -1:
                q.append((nx,ny))
    else:
        black[x][y] = 0
    count += 1
print("No")
0