結果

問題 No.1588 Connection
ユーザー chineristACchineristAC
提出日時 2021-07-08 22:37:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,344 KB
実行使用メモリ 100,364 KB
平均クエリ数 647.66
最終ジャッジ日時 2023-09-24 10:46:37
合計ジャッジ時間 7,445 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
90,476 KB
testcase_01 AC 126 ms
90,492 KB
testcase_02 AC 123 ms
89,896 KB
testcase_03 AC 122 ms
90,616 KB
testcase_04 AC 125 ms
90,500 KB
testcase_05 AC 124 ms
90,840 KB
testcase_06 AC 127 ms
91,008 KB
testcase_07 AC 121 ms
91,048 KB
testcase_08 AC 130 ms
90,116 KB
testcase_09 AC 132 ms
90,684 KB
testcase_10 AC 126 ms
90,428 KB
testcase_11 AC 131 ms
90,704 KB
testcase_12 AC 199 ms
97,756 KB
testcase_13 AC 229 ms
98,252 KB
testcase_14 AC 127 ms
94,816 KB
testcase_15 AC 127 ms
94,032 KB
testcase_16 AC 129 ms
94,568 KB
testcase_17 AC 131 ms
94,628 KB
testcase_18 AC 130 ms
94,552 KB
testcase_19 AC 132 ms
94,472 KB
testcase_20 AC 135 ms
94,264 KB
testcase_21 AC 290 ms
100,364 KB
testcase_22 AC 288 ms
100,104 KB
testcase_23 AC 203 ms
96,032 KB
testcase_24 AC 164 ms
94,372 KB
testcase_25 AC 227 ms
99,976 KB
testcase_26 AC 225 ms
99,280 KB
testcase_27 AC 159 ms
94,908 KB
testcase_28 AC 156 ms
94,896 KB
testcase_29 AC 271 ms
97,820 KB
testcase_30 AC 275 ms
97,936 KB
testcase_31 AC 122 ms
90,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def query(a,b):
    print("{} {}".format(a+1,b+1))
    sys.stdout.flush()
    res = input()
    assert res!="-1"
    return res=="Black"

N,M = mi()

connect = [[False for j in range(N)] for i in range(N)]
connect[0][0] = True
stack = [(0,0)]
move = [(-1,0),(0,-1),(1,0),(0,1)]
while stack:
    h,w = stack.pop()
    for x,y in move:
        nx,ny = h+x,w+y
        if 0<=nx<N and 0<=ny<N and not connect[nx][ny]:
            check = query(nx,ny)
            if check:
                connect[nx][ny] = True
                stack.append((nx,ny))

print("Yes" if connect[-1][-1] else "No")
0