結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,832 KB
testcase_01 AC 26 ms
23,952 KB
testcase_02 AC 24 ms
24,156 KB
testcase_03 AC 25 ms
24,264 KB
testcase_04 AC 24 ms
23,988 KB
testcase_05 AC 25 ms
23,364 KB
testcase_06 AC 25 ms
24,300 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
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 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 25 ms
24,240 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;
            }
        }
        cerr << ok << endl;
        int tmp = i, nxt = i;
        for(int j=ok;j<=i;++j) {
            nxt = v[j];
            v[j] = tmp;
            tmp = nxt;
        }
        for(int j=0;j<n;++j) cerr << v[j] << " ";
        cerr << endl;
    }

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