結果

問題 No.850 企業コンテスト2位
ユーザー treeonetreeone
提出日時 2019-07-05 23:32:21
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,412 bytes
コンパイル時間 2,505 ms
コンパイル使用メモリ 214,056 KB
実行使用メモリ 24,360 KB
平均クエリ数 216.14
最終ジャッジ日時 2023-09-23 17:43:10
合計ジャッジ時間 6,259 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,964 KB
testcase_01 AC 23 ms
23,304 KB
testcase_02 AC 24 ms
23,772 KB
testcase_03 AC 23 ms
23,496 KB
testcase_04 AC 24 ms
23,508 KB
testcase_05 AC 23 ms
23,316 KB
testcase_06 AC 22 ms
23,544 KB
testcase_07 AC 28 ms
24,120 KB
testcase_08 AC 28 ms
23,700 KB
testcase_09 AC 30 ms
24,192 KB
testcase_10 WA -
testcase_11 AC 33 ms
24,072 KB
testcase_12 WA -
testcase_13 AC 34 ms
23,904 KB
testcase_14 AC 33 ms
23,328 KB
testcase_15 AC 33 ms
23,268 KB
testcase_16 AC 31 ms
23,568 KB
testcase_17 WA -
testcase_18 AC 33 ms
23,928 KB
testcase_19 AC 38 ms
24,084 KB
testcase_20 AC 39 ms
23,628 KB
testcase_21 WA -
testcase_22 AC 34 ms
24,360 KB
testcase_23 AC 33 ms
23,640 KB
testcase_24 AC 32 ms
23,652 KB
testcase_25 AC 34 ms
23,304 KB
testcase_26 WA -
testcase_27 AC 23 ms
24,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a;
    rep(i, 0, n) a.push_back(i);
    int win = -1;
    vector<vector<int> > lose(n);
    while(1){
        if(a.size() == 1){
            win = a[0];
            break;
        }
        vector<int> b;
        for(int i = 0; i < a.size() / 2; i++){
            cout << "? " << a[i * 2] + 1 << ' ' << a[i * 2 + 1] + 1 << endl;
            int in;
            cin >> in;
            in--;
            b.push_back(in); 
            if(a[i * 2] == in) lose[a[i * 2]].push_back(a[i * 2 + 1]);
            else lose[a[i * 2 + 1]].push_back(a[i * 2]);
        }
        if(a.size() % 2 == 1){
            b.push_back(a.back());
        }
        a = b;
    }
    int m = lose[win].size();
    vector<P> c(m);
    rep(i, 0, m) c[i] = {0, lose[win][i]};
    rep(i, 0, m){
        rep(j, i + 1, m){
            cout << "? " << lose[win][i] + 1 << ' ' << lose[win][j] + 1 << endl;
            int in;
            cin >> in;
            in--;
            if(in == lose[win][i]) c[i].first++;
            else c[j].first++;
        }
    }
    sort(c.rbegin(), c.rend());
    cout << "! " << c[0].second + 1 << endl;
}
0