結果

問題 No.850 企業コンテスト2位
ユーザー parukiparuki
提出日時 2019-07-10 16:58:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 1,333 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 166,348 KB
実行使用メモリ 24,216 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-23 17:51:56
合計ジャッジ時間 4,222 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,096 KB
testcase_01 AC 25 ms
23,316 KB
testcase_02 AC 25 ms
23,976 KB
testcase_03 AC 24 ms
23,364 KB
testcase_04 AC 25 ms
23,652 KB
testcase_05 AC 25 ms
23,364 KB
testcase_06 AC 25 ms
23,628 KB
testcase_07 AC 29 ms
24,000 KB
testcase_08 AC 31 ms
23,376 KB
testcase_09 AC 31 ms
23,892 KB
testcase_10 AC 35 ms
23,508 KB
testcase_11 AC 35 ms
24,036 KB
testcase_12 AC 35 ms
23,640 KB
testcase_13 AC 34 ms
23,340 KB
testcase_14 AC 35 ms
24,204 KB
testcase_15 AC 34 ms
23,988 KB
testcase_16 AC 34 ms
23,364 KB
testcase_17 AC 36 ms
23,520 KB
testcase_18 AC 35 ms
23,928 KB
testcase_19 AC 34 ms
23,364 KB
testcase_20 AC 35 ms
24,084 KB
testcase_21 AC 36 ms
23,628 KB
testcase_22 AC 35 ms
24,216 KB
testcase_23 AC 35 ms
23,328 KB
testcase_24 AC 36 ms
23,628 KB
testcase_25 AC 36 ms
23,796 KB
testcase_26 AC 36 ms
23,988 KB
testcase_27 AC 25 ms
23,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int query(int x, int y) {
    if (y == 0)return x;
    else if (x == 0)return y;
    cout << "? " << x << ' ' << y << endl;
    int res;
    cin >> res;
    return res;
}

int N;
vi lost[301];

// (l, r]
int f(int l, int r) {
    if (r - l == 1) {
        if (r > N)return 0;
        else return r;
    }
    int m = (l + r) / 2;
    int x = f(l, m);
    int y = f(m, r);
    int res = query(x, y);
    if (res^x^y) {
        lost[res].push_back(res^x^y);
    }
    return res;
}

void solve() {
    cin >> N;
    int n = 1;
    while (n < N)n *= 2;
    int champ = f(0, n);
    int sec = lost[champ][0];
    FOR(i, 1, sz(lost[champ])) {
        sec = query(sec, lost[champ][i]);
    }
    cout << "! " << sec << endl;
}

int main() {
	solve();
	return 0;
}
0