結果
問題 | No.850 企業コンテスト2位 |
ユーザー |
|
提出日時 | 2019-09-10 00:39:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 846 bytes |
コンパイル時間 | 1,817 ms |
コンパイル使用メモリ | 170,248 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 200.29 |
最終ジャッジ日時 | 2024-07-16 18:08:19 |
合計ジャッジ時間 | 4,056 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> winners(2 * N, 0); for (int p = 1; p <= N; ++p) winners[p + N - 1] = p; for (int m = N - 1; m > 0; --m){ cout << "? " << winners[m * 2] << ' ' << winners[m * 2 + 1] << endl; cin >> winners[m]; } vector<int> candidates; int pos = 1; while (pos < N){ if (winners[pos] == winners[pos * 2]){ candidates.push_back(winners[pos * 2 + 1]); pos = pos * 2; }else{ candidates.push_back(winners[pos * 2]); pos = pos * 2 + 1; } } int ans = candidates[0]; for (int i = 1; i < candidates.size(); ++i){ cout << "? " << ans << ' ' << candidates[i] << endl; cin >> ans; } cout << "! " << ans << endl; return 0; }