結果
問題 | No.1588 Connection |
ユーザー |
|
提出日時 | 2021-07-08 22:37:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 233 ms / 2,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 227 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 96,560 KB |
平均クエリ数 | 647.66 |
最終ジャッジ日時 | 2024-07-17 11:38:25 |
合計ジャッジ時間 | 5,504 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
ソースコード
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")