結果
問題 | No.850 企業コンテスト2位 |
ユーザー |
![]() |
提出日時 | 2019-07-06 20:40:18 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 654 bytes |
コンパイル時間 | 1,835 ms |
コンパイル使用メモリ | 97,612 KB |
最終ジャッジ日時 | 2025-01-07 06:22:12 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }