結果

問題 No.1588 Connection
ユーザー 👑 rin204rin204
提出日時 2022-01-26 17:25:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 96,968 KB
平均クエリ数 414.06
最終ジャッジ日時 2023-08-24 23:00:43
合計ジャッジ時間 7,415 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 96 ms
86,804 KB
testcase_02 AC 96 ms
87,412 KB
testcase_03 AC 95 ms
86,472 KB
testcase_04 AC 94 ms
86,616 KB
testcase_05 AC 96 ms
86,924 KB
testcase_06 AC 97 ms
86,972 KB
testcase_07 AC 95 ms
87,184 KB
testcase_08 WA -
testcase_09 AC 102 ms
87,424 KB
testcase_10 AC 99 ms
86,856 KB
testcase_11 AC 102 ms
87,032 KB
testcase_12 AC 191 ms
94,100 KB
testcase_13 AC 157 ms
92,880 KB
testcase_14 AC 95 ms
87,284 KB
testcase_15 AC 102 ms
87,352 KB
testcase_16 AC 96 ms
86,772 KB
testcase_17 AC 98 ms
87,124 KB
testcase_18 AC 97 ms
86,876 KB
testcase_19 AC 97 ms
87,480 KB
testcase_20 AC 99 ms
87,416 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 160 ms
92,348 KB
testcase_24 AC 127 ms
90,980 KB
testcase_25 AC 198 ms
95,632 KB
testcase_26 AC 195 ms
95,752 KB
testcase_27 AC 134 ms
91,092 KB
testcase_28 AC 122 ms
91,732 KB
testcase_29 WA -
testcase_30 AC 177 ms
93,468 KB
testcase_31 AC 96 ms
87,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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")
0