結果

問題 No.1588 Connection
ユーザー convexineqconvexineq
提出日時 2021-07-09 04:39:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 96,208 KB
平均クエリ数 484.88
最終ジャッジ日時 2023-09-24 11:57:15
合計ジャッジ時間 6,602 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
87,448 KB
testcase_01 AC 102 ms
87,644 KB
testcase_02 AC 102 ms
87,160 KB
testcase_03 AC 100 ms
87,112 KB
testcase_04 AC 102 ms
87,136 KB
testcase_05 AC 102 ms
87,448 KB
testcase_06 AC 104 ms
86,992 KB
testcase_07 AC 101 ms
87,256 KB
testcase_08 AC 107 ms
87,704 KB
testcase_09 AC 104 ms
87,188 KB
testcase_10 AC 104 ms
87,112 KB
testcase_11 AC 104 ms
87,372 KB
testcase_12 AC 111 ms
87,128 KB
testcase_13 AC 113 ms
86,872 KB
testcase_14 AC 103 ms
87,244 KB
testcase_15 AC 106 ms
87,300 KB
testcase_16 AC 105 ms
86,868 KB
testcase_17 AC 104 ms
87,628 KB
testcase_18 AC 103 ms
87,140 KB
testcase_19 AC 102 ms
87,704 KB
testcase_20 AC 105 ms
87,280 KB
testcase_21 AC 269 ms
95,952 KB
testcase_22 AC 269 ms
96,208 KB
testcase_23 AC 169 ms
92,356 KB
testcase_24 AC 137 ms
91,592 KB
testcase_25 AC 204 ms
95,820 KB
testcase_26 AC 192 ms
95,456 KB
testcase_27 AC 138 ms
91,708 KB
testcase_28 AC 127 ms
87,592 KB
testcase_29 AC 261 ms
93,492 KB
testcase_30 AC 257 ms
93,248 KB
testcase_31 AC 102 ms
87,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def query(a,b):
    print(f"{a+1} {b+1}",flush=1)
    if DEBUG:
        return a!=1 or b!=1
    else:
        return input() == "Black"

DEBUG = 0
n,m = map(int,input().split())
b = [[0]*n for _ in range(n)]
b[0][0] = b[-1][-1] = 1
q = [(0,0)]
while q:
    i,j = q.pop()
    for ni,nj in [(i-1,j),(i,j-1),(i+1,j),(i,j+1)]:
        if ni == nj == n-1:
            print("Yes")
            exit()
        if 0 <= ni < n and 0 <= nj < n and b[ni][nj] == 0:
            b[ni][nj] = 1
            if query(ni,nj):
                q.append((ni,nj))
print("No")
0