結果

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

テストケース

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

ソースコード

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(i == v[0]) continue;
        cout << "? " << v[1] << ' ' << cand[i] << endl;
        cin >> winner;
        if(winner == i) {
            v[1] = i;
        }
    }

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