結果

問題 No.1588 Connection
ユーザー shotoyooshotoyoo
提出日時 2021-07-08 23:22:21
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 1,622 bytes
コンパイル時間 230 ms
使用メモリ 98,720 KB
平均クエリ数 557.78
最終ジャッジ日時 2023-02-15 01:11:24
合計ジャッジ時間 6,026 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 87 ms
90,288 KB
testcase_01 AC 89 ms
90,232 KB
testcase_02 AC 87 ms
90,596 KB
testcase_03 AC 87 ms
90,440 KB
testcase_04 AC 87 ms
90,236 KB
testcase_05 AC 87 ms
90,992 KB
testcase_06 AC 89 ms
90,004 KB
testcase_07 AC 88 ms
90,420 KB
testcase_08 AC 91 ms
90,152 KB
testcase_09 AC 93 ms
90,848 KB
testcase_10 AC 92 ms
90,496 KB
testcase_11 AC 95 ms
90,156 KB
testcase_12 AC 158 ms
95,904 KB
testcase_13 AC 168 ms
97,540 KB
testcase_14 AC 86 ms
91,024 KB
testcase_15 AC 87 ms
90,796 KB
testcase_16 AC 87 ms
90,260 KB
testcase_17 AC 88 ms
90,420 KB
testcase_18 AC 87 ms
90,388 KB
testcase_19 AC 86 ms
90,256 KB
testcase_20 AC 89 ms
90,460 KB
testcase_21 AC 228 ms
98,448 KB
testcase_22 AC 226 ms
98,720 KB
testcase_23 AC 154 ms
95,924 KB
testcase_24 AC 124 ms
95,540 KB
testcase_25 AC 172 ms
97,888 KB
testcase_26 AC 169 ms
98,036 KB
testcase_27 AC 122 ms
95,032 KB
testcase_28 AC 108 ms
90,740 KB
testcase_29 AC 230 ms
96,796 KB
testcase_30 AC 234 ms
97,140 KB
testcase_31 AC 85 ms
90,516 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]
count = 0
def query(x,y):
    print(x+1,y+1)
    sys.stdout.flush()
    res = input()
    global count
    count += 1
    if res=="Black":
        return 1
    elif res=="White":
        return 0
    assert 0
def sub(x,y):
    if done[x][y]:
        return
    res = query(x,y)
    if res:
        q.append((x,y))
    done[x][y] = 1
if __name__=="__main__":
    val = input()
    n,m = map(int, val.split())
    done = [[0]*n for _ in range(n)]
    q = [(0,0)]
    done[0][0] = 1
    while q:
        x,y = q.pop()
        if x==y==n-1:
            print("Yes")
            break
        if x+1<n:
            sub(x+1,y)
            if count==3000:
                break
        if x-1>=0:
            sub(x-1,y)
            if count==3000:
                break
        if y+1<n:
            sub(x,y+1)
            if count==3000:
                break
        if y-1>=0:
            sub(x,y-1)
            if count==3000:
                break
    else:
        if count==3000:
            print("Yes")
        else:
            print("No")
0