結果

問題 No.850 企業コンテスト2位
ユーザー rpy3cpprpy3cpp
提出日時 2019-09-10 00:39:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 168,016 KB
実行使用メモリ 24,336 KB
平均クエリ数 200.29
最終ジャッジ日時 2023-09-23 18:14:05
合計ジャッジ時間 3,850 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,388 KB
testcase_01 AC 24 ms
24,336 KB
testcase_02 AC 22 ms
23,388 KB
testcase_03 AC 23 ms
23,676 KB
testcase_04 AC 23 ms
23,544 KB
testcase_05 AC 23 ms
24,072 KB
testcase_06 AC 24 ms
23,544 KB
testcase_07 AC 26 ms
23,388 KB
testcase_08 AC 28 ms
24,276 KB
testcase_09 AC 29 ms
23,556 KB
testcase_10 AC 31 ms
24,036 KB
testcase_11 AC 32 ms
23,412 KB
testcase_12 AC 33 ms
23,244 KB
testcase_13 AC 32 ms
23,844 KB
testcase_14 AC 30 ms
24,060 KB
testcase_15 AC 30 ms
23,376 KB
testcase_16 AC 31 ms
24,336 KB
testcase_17 AC 32 ms
23,388 KB
testcase_18 AC 32 ms
24,036 KB
testcase_19 AC 32 ms
24,264 KB
testcase_20 AC 32 ms
24,336 KB
testcase_21 AC 33 ms
24,336 KB
testcase_22 AC 32 ms
23,424 KB
testcase_23 AC 32 ms
24,036 KB
testcase_24 AC 32 ms
23,400 KB
testcase_25 AC 32 ms
24,324 KB
testcase_26 AC 34 ms
24,036 KB
testcase_27 AC 21 ms
23,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> winners(2 * N, 0);
    for (int p = 1; p <= N; ++p) winners[p + N - 1] = p;
    for (int m = N - 1; m > 0; --m){
        cout << "? " << winners[m * 2] << ' ' << winners[m * 2 + 1] << endl;
        cin >> winners[m];
    }
    vector<int> candidates;
    int pos = 1;
    while (pos < N){
        if (winners[pos] == winners[pos * 2]){
            candidates.push_back(winners[pos * 2 + 1]);
            pos = pos * 2;
        }else{
            candidates.push_back(winners[pos * 2]);
            pos = pos * 2 + 1;
        }
    }
    int ans = candidates[0];
    for (int i = 1; i < candidates.size(); ++i){
        cout << "? " << ans << ' ' << candidates[i] << endl;
        cin >> ans;
    }
    cout << "! " << ans << endl;
    return 0;
}
0