結果

問題 No.850 企業コンテスト2位
コンテスト
ユーザー nimon
提出日時 2019-08-30 23:28:58
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 580 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,417 ms
コンパイル使用メモリ 69,876 KB
実行使用メモリ 9,532 KB
平均クエリ数 194.79
最終ジャッジ日時 2026-08-14 11:38:32
合計ジャッジ時間 6,709 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 3 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from strutils import parseInt
from sequtils import mapIt

let N = stdin.readLine.parseInt

var participants = (1..N).mapIt(it)

proc ask(x, y: int): int =
  echo "? ", x, " ", y
  stdin.readLine.parseInt

var next = newSeq[int]()
while participants.len > 2:
  next = @[]
  for i in countup(1, participants.high, 2):
    let ans = ask(participants[i - 1], participants[i])
    next.add(ans)
  if participants.len mod 2 == 1:
    next.add(participants[^1])
  participants = next

let ans = ask(participants[0], participants[1])
echo "! ", participants[participants.find(ans) xor 1]
0