結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-26 17:25:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 1,000 ms |
| コンパイル使用メモリ | 82,332 KB |
| 実行使用メモリ | 96,644 KB |
| 平均クエリ数 | 414.06 |
| 最終ジャッジ日時 | 2024-12-23 09:27:39 |
| 合計ジャッジ時間 | 6,657 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 WA * 5 |
ソースコード
import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
used = [[False] * n for _ in range(n)]
def dfs(i, j):
global m
for di, dj in directions:
ni = i + di
nj = j + dj
if ni == -1 or nj == -1 or ni == n or nj == n:
continue
if used[ni][nj]:
continue
if nj == n - 1 and nj == n - 1:
print("Yes")
exit()
used[ni][nj] = True
print(ni + 1, nj + 1, flush = True)
t = input()
if t == "-1":
exit()
elif t == "Black":
dfs(ni, nj)
else:
m -= 1
if m == 0:
print("No")
exit()
used[0][0] = True
used[-1][-1] = True
dfs(0, 0)
print("No")