結果
| 問題 | No.2252 Find Zero |
| コンテスト | |
| ユーザー |
0214sh7
|
| 提出日時 | 2023-03-24 22:02:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,921 bytes |
| コンパイル時間 | 1,884 ms |
| コンパイル使用メモリ | 199,532 KB |
| 最終ジャッジ日時 | 2025-02-11 17:18:43 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define ALL(v) (v).begin(), (v).end()
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug true
#define debug2 false
ll N;
void phase1_input(){
cin >> N;
}
ll phase2_query(ll x,ll y){
cout << "? " << x << " " << y << endl;
ll z;
cin >> z;
return z;
}
void phase2_answer(ll k){
cout << "! " << k << endl;
exit(0);
}
int main(void){
//cin.tie(nullptr);
//ios::sync_with_stdio(false);
phase1_input();
if(N==3 || N==5 || N==7){
set<ll> R;
REP(i,N){R.insert(i);}
REP(i,(N-1)/2){
auto it = R.begin();
ll t1 = *it;
R.erase(it);
auto it2 = R.begin();
ll t2 = *it2;
R.erase(it2);
ll s = phase2_query(t1,t2);
if(s==t1){
phase2_answer(t2);
}else if(s==t2){
phase2_answer(t1);
}
}
auto it = R.begin();
ll t = *it;
R.erase(it);
phase2_answer(t);
}else{
ll two = 1;
vector<ll> D = {0};
while(2*two-1 < N){
ll d = D.back();
D.push_back(phase2_query(d,d));
two *= 2;
}
ll a = -1;
for(ll i=0;i<N;i++){
if((N>>i)%2==0)continue;
if(a==-1){
a = D[i];
}else{
a = phase2_query(D[i],a);
}
}
phase2_answer(a);
}
return 0;
}
0214sh7