結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-08 23:03:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 881 bytes |
| コンパイル時間 | 732 ms |
| コンパイル使用メモリ | 73,428 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 200.18 |
| 最終ジャッジ日時 | 2024-07-16 17:43:45 |
| 合計ジャッジ時間 | 4,150 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 24 WA * 2 RE * 1 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
vector<int> defeat[300];
int ask(int x, int y){
cout << "? " << x << " " << y << endl << flush;
int ret;
cin >> ret;
if(ret == x) defeat[x].push_back(y);
else defeat[y].push_back(x);
return ret;
}
void answer(int x){
cout << "! " << x << endl << flush;
}
void shrink(vector<int> &a){
while(a.size() > 2){
vector<int> b;
int pos = 0;
while(pos+1 < a.size()){
b.push_back(ask(a[pos], a[pos+1]));
pos += 2;
}
if(pos < a.size()) b.push_back(a[pos]);
a = b;
}
}
int main(){
int n;
cin >> n;
vector<int> a;
for(int i = 1; i <= n; i++) a.push_back(i);
shrink(a);
int top = ask(a[0], a[1]);
shrink(defeat[top]);
answer(ask(defeat[top][0], defeat[top][1]));
return 0;
}