結果

問題 No.850 企業コンテスト2位
ユーザー noisy_noimin
提出日時 2019-07-05 23:18:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,267 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 98,948 KB
実行使用メモリ 25,476 KB
平均クエリ数 1372.18
最終ジャッジ日時 2024-07-16 17:33:52
合計ジャッジ時間 11,521 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 18 RE * 2
権限があれば一括ダウンロードができます

ソースコード

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