結果

問題 No.1588 Connection
ユーザー tcltktcltk
提出日時 2021-11-19 23:18:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 101,452 KB
平均クエリ数 562.31
最終ジャッジ日時 2023-08-30 10:31:32
合計ジャッジ時間 10,878 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 226 ms
96,376 KB
testcase_01 WA -
testcase_02 AC 224 ms
96,552 KB
testcase_03 AC 222 ms
97,032 KB
testcase_04 AC 223 ms
97,060 KB
testcase_05 AC 221 ms
97,088 KB
testcase_06 AC 223 ms
96,412 KB
testcase_07 AC 221 ms
97,152 KB
testcase_08 AC 224 ms
96,232 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 222 ms
96,656 KB
testcase_15 AC 225 ms
96,860 KB
testcase_16 AC 224 ms
96,768 KB
testcase_17 AC 223 ms
96,864 KB
testcase_18 AC 222 ms
97,124 KB
testcase_19 AC 221 ms
97,060 KB
testcase_20 AC 232 ms
100,068 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 311 ms
101,416 KB
testcase_26 AC 301 ms
101,388 KB
testcase_27 AC 253 ms
99,856 KB
testcase_28 AC 244 ms
98,432 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

def input_wrapper(i, j):
    global query_count

    if Map[i][j] != -1:
        return Map[i][j]
    
    if query_count == 3000:
        return 0
    query_count += 1

    print(i+1, j+1)
    sys.stdout.flush()
    v = input()
    if v == 'Black':
        Map[i][j] = 1
        return 1
    elif v == 'White':
        Map[i][j] = 0
        return 0
    else:
        sys.exit()

def solve(N, M):
    hq = []
    heapq.heappush(hq, ((N-1)+(N-1), 0, 0))
    while hq:
        d, i, j = heapq.heappop(hq)
        for i1, j1 in [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]:
            if not (0 <= i1 < N and 0 <= j1 < N and Map[i1][j1] == -1):
                continue
            d1 = (N-1-i1) + (N-1-j1)
            v = input_wrapper(i1, j1)
            if v == 1:
                if (i1, j1) == (N-1, N-1):
                    return'Yes'
                heapq.heappush(hq, (d1, i1, j1))
    return 'No'        


N, M = map(int, input().split())
Map = [[-1] * N for _ in range(N)]
Map[0][0] = 1
Map[N-1][N-1] = 1
query_count = 0
print(solve(N, M))
sys.stdout.flush()
0