結果

問題 No.850 企業コンテスト2位
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-07-05 23:40:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,315 bytes
コンパイル時間 891 ms
コンパイル使用メモリ 95,168 KB
実行使用メモリ 24,336 KB
平均クエリ数 298.79
最終ジャッジ日時 2023-09-23 17:44:41
合計ジャッジ時間 4,895 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,568 KB
testcase_01 AC 23 ms
23,784 KB
testcase_02 AC 23 ms
24,012 KB
testcase_03 AC 21 ms
24,180 KB
testcase_04 AC 23 ms
23,604 KB
testcase_05 AC 23 ms
24,324 KB
testcase_06 AC 23 ms
23,340 KB
testcase_07 AC 26 ms
23,328 KB
testcase_08 AC 30 ms
24,204 KB
testcase_09 AC 32 ms
23,328 KB
testcase_10 WA -
testcase_11 AC 32 ms
23,328 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 32 ms
23,496 KB
testcase_15 AC 33 ms
23,604 KB
testcase_16 AC 33 ms
24,036 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 34 ms
23,604 KB
testcase_20 AC 33 ms
24,096 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 22 ms
23,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    int n, winner;
    cin >> n;
    vector<int> v(2, -1);
    vector<int> lose(n+1, -1);
    v[0] = 1;
    for(int i=2;i<=n;++i) {
        cout << "? " << v[0] << ' ' << i << endl;
        cin >> winner;
        if(winner == i) {
            lose[v[0]] = i;
            v[0] = i;
        } else {
            lose[i] = v[0];
        }
    }

    vector<int> cand;
    for(int i=1;i<=n;++i) {
        if(lose[i] == v[0]) {
            cand.push_back(i);
        }
    }

    v[1] = cand[0];
    for(int i=1;i<cand.size();++i) {
        if(cand[i] == v[0]) continue;
        cout << "? " << v[1] << ' ' << cand[i] << endl;
        cin >> winner;
        if(winner == cand[i]) {
            v[1] = cand[i];
        }
    }

    cout << "! " << v[1] << endl;
}
0