結果
問題 |
No.850 企業コンテスト2位
|
ユーザー |
![]() |
提出日時 | 2019-07-06 20:47:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 643 bytes |
コンパイル時間 | 630 ms |
コンパイル使用メモリ | 73,356 KB |
最終ジャッジ日時 | 2025-01-07 06:24:20 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 |
other | WA * 2 TLE * 25 |
コンパイルメッセージ
main.cpp: In function ‘int max(std::vector<int>&)’: main.cpp:29:30: warning: control reaches end of non-void function [-Wreturn-type] 29 | cout << "! " << x << endl; | ^~~~
ソースコード
#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]); } cout << "! " << x << endl; } int main(){ int i; cin >> n; for(i=0;i<n;i++){ t[i + n] = i + 1; } int x = build(); max(v[x]); }