結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
pockyny
|
| 提出日時 | 2019-07-06 20:45:15 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 650 bytes |
| コンパイル時間 | 2,071 ms |
| コンパイル使用メモリ | 97,052 KB |
| 最終ジャッジ日時 | 2025-01-07 06:22:54 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | AC * 2 RE * 25 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int n,t[610] = {};
vector<int> v[310];
int query(int a, int b){
if(a==b) return a;
if(a==0) return b;
if(b==0) return a;
cout << "? " << a << " " << b << endl;
int c; cin >> c;
v[c].push_back(a^b^c);
return c;
}
int build(){
for(int i=n-1;i>0;i--){
t[i] = query(t[i<<1],t[i<<1|1]);
}
return t[1];
}
int max(vector<int> &a){
if(a.size()==1) return a[0];
int x = query(a[0],a[1]);
for(int i=2;i<a.size();i++){
x = query(x,a[i]);
}
return x;
}
int main(){
int i;
cin >> n;
for(i=0;i<n;i++){
t[i + n] = i + 1;
}
int x = build();
cout << "! " << max(v[x]) << endl;
}
pockyny