結果

問題 No.2252 Find Zero
ユーザー 0214sh70214sh7
提出日時 2023-03-24 22:09:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,360 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 206,888 KB
実行使用メモリ 24,624 KB
平均クエリ数 78.11
最終ジャッジ日時 2023-10-18 21:07:02
合計ジャッジ時間 4,409 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
24,624 KB
testcase_01 AC 76 ms
24,624 KB
testcase_02 AC 55 ms
24,624 KB
testcase_03 AC 66 ms
24,624 KB
testcase_04 AC 56 ms
24,624 KB
testcase_05 AC 54 ms
24,624 KB
testcase_06 AC 54 ms
24,624 KB
testcase_07 AC 58 ms
24,624 KB
testcase_08 AC 62 ms
24,624 KB
testcase_09 AC 67 ms
24,624 KB
testcase_10 AC 53 ms
24,624 KB
testcase_11 AC 54 ms
24,624 KB
testcase_12 AC 54 ms
24,624 KB
testcase_13 AC 53 ms
24,624 KB
testcase_14 AC 53 ms
24,624 KB
testcase_15 AC 54 ms
24,624 KB
testcase_16 AC 53 ms
24,624 KB
testcase_17 AC 54 ms
24,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();

    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);
    
    return 0;
}
0