結果

問題 No.1187 皇帝ペンギン
ユーザー marroncastlemarroncastle
提出日時 2020-08-22 15:08:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 48 ms / 1,000 ms
コード長 716 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 24,376 KB
平均クエリ数 18.37
最終ジャッジ日時 2023-09-24 06:07:33
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
23,648 KB
testcase_01 AC 40 ms
23,704 KB
testcase_02 AC 39 ms
23,596 KB
testcase_03 AC 40 ms
24,228 KB
testcase_04 AC 39 ms
23,940 KB
testcase_05 AC 41 ms
23,888 KB
testcase_06 AC 40 ms
23,480 KB
testcase_07 AC 40 ms
23,736 KB
testcase_08 AC 40 ms
24,228 KB
testcase_09 AC 40 ms
24,164 KB
testcase_10 AC 40 ms
23,608 KB
testcase_11 AC 41 ms
23,776 KB
testcase_12 AC 40 ms
23,620 KB
testcase_13 AC 40 ms
23,980 KB
testcase_14 AC 40 ms
23,956 KB
testcase_15 AC 40 ms
23,772 KB
testcase_16 AC 39 ms
23,540 KB
testcase_17 AC 40 ms
24,124 KB
testcase_18 AC 39 ms
23,608 KB
testcase_19 AC 40 ms
23,484 KB
testcase_20 AC 38 ms
24,276 KB
testcase_21 AC 39 ms
24,372 KB
testcase_22 AC 38 ms
23,636 KB
testcase_23 AC 38 ms
23,624 KB
testcase_24 AC 39 ms
23,756 KB
testcase_25 AC 38 ms
23,704 KB
testcase_26 AC 36 ms
23,572 KB
testcase_27 AC 36 ms
23,976 KB
testcase_28 AC 38 ms
23,864 KB
testcase_29 AC 35 ms
23,952 KB
testcase_30 AC 38 ms
23,952 KB
testcase_31 AC 38 ms
24,228 KB
testcase_32 AC 39 ms
24,288 KB
testcase_33 AC 37 ms
23,500 KB
testcase_34 AC 37 ms
24,276 KB
testcase_35 AC 38 ms
23,648 KB
testcase_36 AC 39 ms
24,200 KB
testcase_37 AC 39 ms
23,908 KB
testcase_38 AC 38 ms
23,548 KB
testcase_39 AC 37 ms
23,740 KB
testcase_40 AC 37 ms
23,556 KB
testcase_41 AC 37 ms
24,008 KB
testcase_42 AC 36 ms
24,344 KB
testcase_43 AC 38 ms
23,752 KB
testcase_44 AC 38 ms
23,696 KB
testcase_45 AC 38 ms
24,252 KB
testcase_46 AC 37 ms
24,376 KB
testcase_47 AC 37 ms
23,468 KB
testcase_48 AC 37 ms
24,252 KB
testcase_49 AC 39 ms
23,540 KB
testcase_50 AC 38 ms
24,276 KB
testcase_51 AC 37 ms
23,692 KB
testcase_52 AC 38 ms
23,828 KB
testcase_53 AC 41 ms
23,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
write = sys.stdout.write
flush = sys.stdout.flush

# クエリ: "? x1 x2" を出力
def query(x):
    write("? %d\n" %x)
    flush()
    # ジャッジから返される値を取得
    return readline().strip()

# 回答: "! x" を出力
def answer(x):
    write("! %d\n" % x)
    flush()
    # 即時終了
    exit(0)

def check(target):
  #checkする処理
  s = query(target)
  if s=='safe':
    return True
  t = query(target-1)
  if t=='safe':
    return True
  return False

low,high = 0,10**3
mid = (low+high)//2
while high-low>1:
  if check(mid):
    low = mid
  else:
    high = mid
  mid = (low+high)//2
if query(mid)=='safe':
  answer(mid)
else:
  answer(mid-1)
0