結果

問題 No.1588 Connection
ユーザー chineristACchineristAC
提出日時 2021-07-08 22:37:15
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 1,168 ms
使用メモリ 103,596 KB
平均クエリ数 647.66
最終ジャッジ日時 2023-02-15 00:04:08
合計ジャッジ時間 8,441 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 135 ms
93,168 KB
testcase_01 AC 135 ms
93,012 KB
testcase_02 AC 138 ms
93,604 KB
testcase_03 AC 140 ms
92,928 KB
testcase_04 AC 139 ms
93,108 KB
testcase_05 AC 138 ms
93,512 KB
testcase_06 AC 141 ms
93,528 KB
testcase_07 AC 139 ms
93,168 KB
testcase_08 AC 143 ms
93,096 KB
testcase_09 AC 147 ms
93,132 KB
testcase_10 AC 146 ms
92,880 KB
testcase_11 AC 143 ms
92,820 KB
testcase_12 AC 240 ms
101,452 KB
testcase_13 AC 287 ms
101,052 KB
testcase_14 AC 147 ms
97,228 KB
testcase_15 AC 146 ms
97,532 KB
testcase_16 AC 142 ms
97,836 KB
testcase_17 AC 142 ms
97,560 KB
testcase_18 AC 140 ms
98,052 KB
testcase_19 AC 142 ms
97,416 KB
testcase_20 AC 149 ms
97,048 KB
testcase_21 AC 325 ms
103,060 KB
testcase_22 AC 325 ms
103,596 KB
testcase_23 AC 232 ms
100,984 KB
testcase_24 AC 178 ms
97,636 KB
testcase_25 AC 257 ms
102,408 KB
testcase_26 AC 261 ms
102,340 KB
testcase_27 AC 178 ms
97,400 KB
testcase_28 AC 170 ms
97,764 KB
testcase_29 AC 308 ms
101,620 KB
testcase_30 AC 327 ms
101,372 KB
testcase_31 AC 137 ms
93,604 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