結果

問題 No.850 企業コンテスト2位
ユーザー nimonnimon
提出日時 2019-08-30 23:58:59
言語 Nim
(2.0.2)
結果
RE  
実行時間 -
コード長 488 bytes
コンパイル時間 3,021 ms
コンパイル使用メモリ 71,000 KB
実行使用メモリ 24,504 KB
平均クエリ数 208.07
最終ジャッジ日時 2023-09-23 18:10:28
合計ジャッジ時間 6,295 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,504 KB
testcase_01 AC 23 ms
23,544 KB
testcase_02 AC 23 ms
24,336 KB
testcase_03 AC 23 ms
23,544 KB
testcase_04 AC 23 ms
23,676 KB
testcase_05 AC 23 ms
24,216 KB
testcase_06 AC 23 ms
24,336 KB
testcase_07 AC 27 ms
23,412 KB
testcase_08 AC 29 ms
23,844 KB
testcase_09 AC 28 ms
23,424 KB
testcase_10 AC 33 ms
23,436 KB
testcase_11 AC 33 ms
23,400 KB
testcase_12 AC 32 ms
24,264 KB
testcase_13 AC 32 ms
24,072 KB
testcase_14 AC 34 ms
23,544 KB
testcase_15 AC 33 ms
24,048 KB
testcase_16 AC 31 ms
24,048 KB
testcase_17 AC 33 ms
24,252 KB
testcase_18 AC 32 ms
24,480 KB
testcase_19 AC 33 ms
23,436 KB
testcase_20 RE -
testcase_21 AC 35 ms
23,556 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 23 ms
23,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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