結果
問題 | No.850 企業コンテスト2位 |
ユーザー |
![]() |
提出日時 | 2019-08-30 23:41:28 |
言語 | Nim (2.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,267 bytes |
コンパイル時間 | 4,215 ms |
コンパイル使用メモリ | 65,408 KB |
実行使用メモリ | 25,716 KB |
平均クエリ数 | 195.71 |
最終ジャッジ日時 | 2024-07-16 18:05:23 |
合計ジャッジ時間 | 10,931 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 WA * 23 |
ソースコード
from strutils import parseIntfrom sequtils import mapItlet N = stdin.readLine.parseIntvar participants = (1..N).mapIt(it)proc ask(x, y: int): int =echo "? ", x, " ", ystdin.readLine.parseIntvar next = newSeq[int]()while participants.len > 4: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 = nextdoAssert participants.len > 1if ask(participants[0], participants[1]) == participants[1]:swap(participants[0], participants[1])case participants.len:of 2:discardof 3:if ask(participants[0], participants[2]) == participants[2]:swap(participants[0], participants[2])if ask(participants[1], participants[2]) == participants[2]:swap(participants[1], participants[2])of 4:if ask(participants[2], participants[3]) == participants[3]:swap(participants[2], participants[3])if ask(participants[0], participants[2]) == participants[2]:swap(participants[0], participants[2])if ask(participants[1], participants[2]) == participants[2]:swap(participants[1], participants[2])else:discardecho "! ", participants[1]