結果

問題 No.850 企業コンテスト2位
ユーザー chaemonchaemon
提出日時 2019-08-30 00:04:22
言語 Nim
(2.0.2)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,335 bytes
コンパイル時間 4,700 ms
コンパイル使用メモリ 71,156 KB
実行使用メモリ 24,288 KB
平均クエリ数 200.07
最終ジャッジ日時 2023-09-23 18:09:42
合計ジャッジ時間 7,396 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,352 KB
testcase_01 AC 24 ms
23,388 KB
testcase_02 AC 23 ms
23,400 KB
testcase_03 AC 25 ms
24,036 KB
testcase_04 AC 23 ms
23,388 KB
testcase_05 AC 23 ms
24,288 KB
testcase_06 AC 22 ms
24,288 KB
testcase_07 AC 27 ms
24,048 KB
testcase_08 AC 29 ms
24,000 KB
testcase_09 AC 29 ms
23,796 KB
testcase_10 AC 33 ms
23,556 KB
testcase_11 AC 35 ms
23,676 KB
testcase_12 AC 34 ms
23,352 KB
testcase_13 AC 32 ms
24,036 KB
testcase_14 AC 33 ms
23,376 KB
testcase_15 AC 33 ms
23,604 KB
testcase_16 AC 32 ms
23,520 KB
testcase_17 AC 31 ms
24,216 KB
testcase_18 AC 33 ms
23,400 KB
testcase_19 AC 33 ms
23,976 KB
testcase_20 AC 34 ms
23,628 KB
testcase_21 AC 33 ms
24,000 KB
testcase_22 AC 33 ms
23,544 KB
testcase_23 AC 34 ms
23,400 KB
testcase_24 AC 33 ms
23,556 KB
testcase_25 AC 34 ms
23,508 KB
testcase_26 AC 33 ms
23,520 KB
testcase_27 AC 23 ms
23,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 37) Warning: imported and not used: 'macros' [UnusedImport]
/home/judge/data/code/Main.nim(2, 19) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(2, 29) Warning: imported and not used: 'tables' [UnusedImport]

ソースコード

diff #

#{{{ header
import algorithm, sequtils, tables, macros, math, sets, strutils, deques
when defined(MYDEBUG):
  import header

import deques
var cin = initDeque[string]()
proc get(cin:var Deque[string]):string =
  while cin.len == 0:
    for s in stdin.readLine.split(' '):
      if s.len > 0: cin.addLast(s)
  return cin.popFirst
proc nextInt(cin:var Deque[string]):int = cin.get.parseInt
proc nextFloat(cin:var Deque[string]):float = cin.get.parseFloat
proc nextString(cin:var Deque[string]):string = cin.get

template `max=`*(x,y:typed):void = x = max(x,y)
template `min=`*(x,y:typed):void = x = min(x,y)
template infty(T): untyped = ((T(1) shl T(sizeof(T)*8-2)) - 1)
#}}}

proc test(x,y:int):int =
  echo "? ",x," ",y
  let ans = cin.nextInt()
  return ans

proc main() =
  let N = cin.nextInt()
  var v = initDeque[(int,seq[int])]()
  for i in 1..N: v.addLast((i,@[]))
  while v.len > 1:
    var v2 = initDeque[(int,seq[int])]()
    while v.len > 0:
      if v.len == 1: v2.addLast(v.popLast)
      else:
        var s,t = v.popLast
        let r = test(s[0],t[0])
        if r == s[0]:
          s[1].add(t[0])
          v2.addLast(s)
        else:
          t[1].add(s[0])
          v2.addLast(t)
    v = v2
  var w = v.popFirst[1]
  var cur = w[0]
  for i in 1..<w.len:
    cur = test(cur,w[i])
  echo "! ",cur
  discard

main()
0