結果

問題 No.1588 Connection
ユーザー 👑 rin204rin204
提出日時 2022-01-26 17:28:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 86,112 KB
実行使用メモリ 96,744 KB
平均クエリ数 328.19
最終ジャッジ日時 2023-08-24 23:03:38
合計ジャッジ時間 6,586 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 101 ms
86,648 KB
testcase_02 AC 101 ms
86,744 KB
testcase_03 AC 102 ms
86,860 KB
testcase_04 AC 101 ms
87,112 KB
testcase_05 AC 100 ms
87,136 KB
testcase_06 AC 102 ms
86,804 KB
testcase_07 AC 100 ms
86,844 KB
testcase_08 WA -
testcase_09 AC 101 ms
86,788 KB
testcase_10 AC 112 ms
87,124 KB
testcase_11 AC 102 ms
87,024 KB
testcase_12 AC 110 ms
87,176 KB
testcase_13 AC 107 ms
86,752 KB
testcase_14 AC 102 ms
86,920 KB
testcase_15 AC 101 ms
87,264 KB
testcase_16 AC 101 ms
86,888 KB
testcase_17 AC 100 ms
86,580 KB
testcase_18 AC 98 ms
86,652 KB
testcase_19 AC 99 ms
87,340 KB
testcase_20 AC 104 ms
86,580 KB
testcase_21 AC 218 ms
95,608 KB
testcase_22 WA -
testcase_23 AC 145 ms
92,036 KB
testcase_24 AC 125 ms
91,108 KB
testcase_25 AC 204 ms
94,804 KB
testcase_26 AC 206 ms
96,204 KB
testcase_27 AC 136 ms
91,192 KB
testcase_28 AC 127 ms
90,956 KB
testcase_29 AC 114 ms
86,872 KB
testcase_30 AC 226 ms
94,180 KB
testcase_31 AC 100 ms
86,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())
directions = [(1, 0), (0, 1), (0, -1), (-1, 0)]

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:
            pass
    
    
    
used[0][0] = True
used[-1][-1] = True
dfs(0, 0)
print("No")
0