結果

問題 No.513 宝探し2
ユーザー nebukuro09nebukuro09
提出日時 2017-05-05 22:38:20
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 77,888 KB
実行使用メモリ 135,856 KB
平均クエリ数 3.25
最終ジャッジ日時 2023-09-24 01:03:28
合計ジャッジ時間 4,155 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
109,400 KB
testcase_01 AC 253 ms
131,720 KB
testcase_02 AC 257 ms
132,248 KB
testcase_03 AC 216 ms
114,736 KB
testcase_04 AC 241 ms
131,992 KB
testcase_05 AC 244 ms
130,732 KB
testcase_06 AC 262 ms
132,004 KB
testcase_07 AC 248 ms
135,684 KB
testcase_08 AC 185 ms
109,760 KB
testcase_09 AC 276 ms
135,856 KB
testcase_10 AC 260 ms
132,948 KB
testcase_11 AC 236 ms
132,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import random

N = 100001
print 0, 0
sys.stdout.flush()
d = int(raw_input())
s = set()
for r in xrange(N):
    c = d - r
    if c < 0:
        continue
    s.add((r, c))

while len(s) > 1:
    r, c = random.sample(s, 1)[0]
    print r, c
    sys.stdout.flush()
    d = int(raw_input())
    new_s = set()
    for dr in xrange(-d, d+1):
        nr = r + dr
        nc = c + d - abs(dr)
        if nr >= 0 and nr < N and nc >= 0 and nc < N:
            new_s.add((nr, nc))
        nc = c - d + abs(dr)
        if nr >= 0 and nr < N and nc >= 0 and nc < N:
            new_s.add((nr, nc))
    s &= new_s

r, c = s.pop()
print r, c
0