結果

問題 No.850 企業コンテスト2位
ユーザー jelljell
提出日時 2019-07-07 11:33:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 2,399 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 174,128 KB
実行使用メモリ 24,204 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-23 17:49:39
合計ジャッジ時間 4,429 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,168 KB
testcase_01 AC 25 ms
23,244 KB
testcase_02 AC 25 ms
23,520 KB
testcase_03 AC 25 ms
24,144 KB
testcase_04 AC 25 ms
23,400 KB
testcase_05 AC 24 ms
23,808 KB
testcase_06 AC 25 ms
23,340 KB
testcase_07 AC 29 ms
23,388 KB
testcase_08 AC 30 ms
23,892 KB
testcase_09 AC 29 ms
23,868 KB
testcase_10 AC 33 ms
23,256 KB
testcase_11 AC 34 ms
23,256 KB
testcase_12 AC 34 ms
23,448 KB
testcase_13 AC 34 ms
23,544 KB
testcase_14 AC 34 ms
23,628 KB
testcase_15 AC 33 ms
23,388 KB
testcase_16 AC 33 ms
23,352 KB
testcase_17 AC 35 ms
24,204 KB
testcase_18 AC 33 ms
23,508 KB
testcase_19 AC 34 ms
23,400 KB
testcase_20 AC 35 ms
23,352 KB
testcase_21 AC 36 ms
23,988 KB
testcase_22 AC 36 ms
23,292 KB
testcase_23 AC 36 ms
23,892 KB
testcase_24 AC 34 ms
23,244 KB
testcase_25 AC 34 ms
23,280 KB
testcase_26 AC 35 ms
23,808 KB
testcase_27 AC 25 ms
23,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using i64=int_fast64_t;
using pii=pair<int,int>;
using pll=pair<i64,i64>;
template <class T> constexpr T inf=numeric_limits<T>::max() / (T)2;
template <class T> using heap=priority_queue<T>;
template <class T> using minheap=priority_queue<T,vector<T>,greater<T>>;
#define fir first
#define sec second
#define mkp make_pair
#define mkt make_tuple
#define emb emplace_back
#define emp emplace
#define all(v) begin(v),end(v)
namespace std {
    template <class T> void hash_combine(size_t &seed, T const &key) {
        seed ^= hash<T>()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    }
    template <class T, class U> struct hash<pair<T,U>> {
        size_t operator()(pair<T,U> const &pr) const
        {
            size_t seed = 0;
            hash_combine(seed,pr.first);
            hash_combine(seed,pr.second);
            return seed;
        }
    };
}
void ios_untie() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void file_setup() {
    if(!freopen("stderr.txt","wt",stderr)) {
        std::cerr << "Failed to open the stderr file\n";
        freopen("CON","wt",stderr);
    }
    if(!freopen("stdout.txt","wt",stdout)) {
        std::cerr << "Failed to open the stdout file\n";
        freopen("CON","wt",stdout);
    }
    if(!freopen("stdin.txt","rt",stdin)) {
        std::cerr << "Failed to open the stdin file.\n";
        freopen("CON","rt",stdin);
    }
}
template <class A, size_t N, class T> void init(A (&array)[N], const T &val) { fill((T*)array,(T*)(array + N),val); }
i64 binry(i64 ok, i64 ng, const function<bool(i64)> &f) {
    while(abs(ok-ng)>1) {
        i64 mid=(ok+ng)/2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

const int __n=512;
int n;
int dat[1024];

int merge(int x,int y) {
    int ret;
    if(max(x,y)<=n) {
        cout<<"? "<<x<<" "<<y<<endl;
        cin>>ret;
    } else {
        ret=min(x,y);
    }
    return ret;
}

void solve() {
    for(int i=__n,t=1; i<__n*2; ++i,++t) {
        dat[i]=t;
    }
    for(int i=__n-1; i; --i) {
        dat[i]=merge(dat[i*2],dat[i*2+1]);
    }
    int _max=dat[1];
    int ix=_max-1+__n;
    dat[ix]=n+1;
    while(ix>>=1) {
        dat[ix]=merge(dat[ix*2],dat[ix*2+1]);
    }
    cout<<"! "<<dat[1]<<endl;
}


signed main() {
    //ios_untie();
#ifdef LOCAL
    file_setup();
#endif
    cin>>n;
    solve();
}
0