結果

問題 No.1588 Connection
ユーザー shotoyooshotoyoo
提出日時 2021-07-08 22:53:47
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,720 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 95,704 KB
平均クエリ数 364.75
最終ジャッジ日時 2023-09-24 10:50:00
合計ジャッジ時間 5,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
87,264 KB
testcase_01 AC 97 ms
87,272 KB
testcase_02 AC 97 ms
87,220 KB
testcase_03 AC 96 ms
87,432 KB
testcase_04 AC 96 ms
87,404 KB
testcase_05 AC 98 ms
87,504 KB
testcase_06 AC 98 ms
86,796 KB
testcase_07 AC 96 ms
86,928 KB
testcase_08 AC 98 ms
87,288 KB
testcase_09 AC 98 ms
87,264 KB
testcase_10 AC 96 ms
87,692 KB
testcase_11 AC 98 ms
87,604 KB
testcase_12 AC 109 ms
87,052 KB
testcase_13 AC 108 ms
87,064 KB
testcase_14 AC 97 ms
87,584 KB
testcase_15 AC 100 ms
87,488 KB
testcase_16 AC 101 ms
87,608 KB
testcase_17 AC 99 ms
86,644 KB
testcase_18 AC 101 ms
87,548 KB
testcase_19 AC 100 ms
87,028 KB
testcase_20 AC 100 ms
86,788 KB
testcase_21 AC 231 ms
95,532 KB
testcase_22 AC 225 ms
95,704 KB
testcase_23 AC 151 ms
92,360 KB
testcase_24 AC 127 ms
91,076 KB
testcase_25 AC 164 ms
92,008 KB
testcase_26 AC 163 ms
92,360 KB
testcase_27 AC 123 ms
91,520 KB
testcase_28 AC 113 ms
87,188 KB
testcase_29 WA -
testcase_30 AC 204 ms
92,960 KB
testcase_31 AC 98 ms
87,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


def answer(i, val):
    write(val)
    sys.stdout.flush()
    # write(f"Case #{i+1}: {val}")
# 標準出力による質問 interactive
import sys
# _l = [2,4,3,1,5,7,6]
# ans = list(range(len(_l)))
# ans.sort(key=lambda i: _l[i])
# ans = [ans[i] for i in range(len(ans))]
# def q(i,j,k):
#     v = sorted([i,j,k], key=lambda i: _l[i])
#     return v[1]
def query(x,y):
    print(x+1,y+1)
    sys.stdout.flush()
    res = input()
    if res=="Black":
        return 1
    elif res=="White":
        return 0
    assert 0
def sub(x,y):
    if x==y==n-1:
        q.append((x,y))
        return 0
    if done[x][y]:
        return 0
    res = query(x,y)
    if res:
        q.append((x,y))
    done[x][y] = 1
    return 1
if __name__=="__main__":
    count = 0
    val = input()
    n,m = map(int, val.split())
    done = [[0]*n for _ in range(n)]
    q = [(0,0)]
    done[0][0] = 1
    M = 3000
    while q:
        x,y = q.pop()
        if x==y==n-1:
            print("Yes")
            break
        if x+1<n:
            count += sub(x+1,y)
            if count>=M:
                break
        if x-1>=0:
            count += sub(x-1,y)
            if count>=M:
                break
        if y+1<n:
            count += sub(x,y+1)
            if count>=M:
                break
        if y-1>=n:
            count += sub(x,y-1)
            if count>=M:
                break
    if (n-1,n-1) in q or (n-2, n-1) in q or (n-1, n-2) in q:
        print("Yes")
    else:
        print("No")
0