結果

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

ソースコード

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
  result = stdin.readLine.parseInt

var two = @[participants[0], participants[1]]

proc swapTow() =
  if ask(two[0], two[1]) == two[1]:
    swap(two[0], two[1])

swapTow()

for i in 2..<N:
  if ask(two[1], participants[i]) == participants[i]:
    swap(two[1], participants[i])
    swapTow()

echo two[1]
0