結果
問題 | No.850 企業コンテスト2位 |
ユーザー | nimon |
提出日時 | 2019-08-31 00:53:43 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 1,223 bytes |
コンパイル時間 | 3,282 ms |
コンパイル使用メモリ | 71,080 KB |
実行使用メモリ | 24,348 KB |
平均クエリ数 | 200.11 |
最終ジャッジ日時 | 2023-09-23 18:12:28 |
合計ジャッジ時間 | 5,400 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
23,388 KB |
testcase_01 | AC | 23 ms
23,400 KB |
testcase_02 | AC | 23 ms
24,024 KB |
testcase_03 | AC | 22 ms
23,388 KB |
testcase_04 | AC | 23 ms
23,640 KB |
testcase_05 | AC | 23 ms
23,376 KB |
testcase_06 | AC | 22 ms
24,336 KB |
testcase_07 | AC | 26 ms
23,568 KB |
testcase_08 | AC | 29 ms
23,388 KB |
testcase_09 | AC | 28 ms
23,844 KB |
testcase_10 | AC | 33 ms
23,436 KB |
testcase_11 | AC | 34 ms
23,844 KB |
testcase_12 | AC | 33 ms
23,664 KB |
testcase_13 | AC | 34 ms
24,336 KB |
testcase_14 | AC | 33 ms
24,060 KB |
testcase_15 | AC | 34 ms
23,244 KB |
testcase_16 | AC | 31 ms
24,348 KB |
testcase_17 | AC | 33 ms
23,664 KB |
testcase_18 | AC | 32 ms
24,024 KB |
testcase_19 | AC | 32 ms
23,544 KB |
testcase_20 | AC | 31 ms
23,856 KB |
testcase_21 | AC | 33 ms
23,412 KB |
testcase_22 | AC | 33 ms
23,568 KB |
testcase_23 | AC | 33 ms
23,424 KB |
testcase_24 | AC | 32 ms
23,436 KB |
testcase_25 | AC | 32 ms
23,604 KB |
testcase_26 | AC | 33 ms
23,412 KB |
testcase_27 | AC | 23 ms
23,664 KB |
ソースコード
from strutils import parseInt from sequtils import mapIt, newSeqWith from algorithm import binarySearch proc ask(x, y: int16): int16 = echo "? ", x, " ", y result = stdin.readLine.parseInt.int16 proc ans(x: int16) = echo "! ", x let N = stdin.readLine.parseInt var histories = newSeqWith(10, newSeq[int16]()) histories[0] = (1..N).mapIt(it.int16) for h in 0..<9: if histories[h].len <= 1: break for i in countup(1, histories[h].high, 2): histories[h + 1].add(ask(histories[h][i - 1], histories[h][i])) if histories[h].len mod 2 == 1: histories[h + 1].add(histories[h][^1]) var results = newSeq[int16]() max: int16 for h in countdown(9, 0): if histories[h].len > 1: let i = histories[h].binarySearch(max) if i mod 2 == 0: if i + 1 < histories[h].len: results.add(histories[h][i + 1]) else: if i - 1 >= 0: results.add(histories[h][i - 1]) elif histories[h].len == 1: max = histories[h][0] continue else: continue var next = newSeq[int16]() while results.len > 1: next = @[] for i in countup(1, results.high, 2): next.add(ask(results[i - 1], results[i])) if results.len mod 2 == 1: next.add(results[^1]) results = next ans(results[0])