結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-10 00:24:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 881 bytes |
| コンパイル時間 | 1,582 ms |
| コンパイル使用メモリ | 170,180 KB |
| 実行使用メモリ | 25,604 KB |
| 平均クエリ数 | 200.68 |
| 最終ジャッジ日時 | 2024-07-16 18:07:58 |
| 合計ジャッジ時間 | 6,307 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 3 WA * 24 |
ソースコード
#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;
int ans;
cin >> ans;
winners[m] = ans;
}
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;
}