結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,264 KB
testcase_01 AC 23 ms
23,364 KB
testcase_02 AC 22 ms
23,604 KB
testcase_03 AC 24 ms
23,628 KB
testcase_04 AC 24 ms
24,180 KB
testcase_05 AC 23 ms
23,688 KB
testcase_06 AC 23 ms
23,976 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 24 ms
24,204 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;
    cin >> n;
    vector<int> v(n, -1);
    v[0] = 1;
    for(int i=2;i<=n;++i) {
        int ng = -1, ok = i-1;
        while(ok-ng > 1) {
            int mid = (ng+ok)/2;
            cout << "? " << v[mid] << ' ' << i << endl;
            int winner = -1;
            cin >> winner;
            if(i == winner) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        int tmp = i, nxt = i;
        for(int j=ok;j<n;++j) {
            nxt = v[j];
            v[j] = tmp;
            tmp = nxt;
        }
    }

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