結果

問題 No.850 企業コンテスト2位
ユーザー jelljell
提出日時 2019-07-06 15:36:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,341 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 173,636 KB
実行使用メモリ 24,360 KB
平均クエリ数 1240.57
最終ジャッジ日時 2023-09-23 17:47:02
合計ジャッジ時間 7,829 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,328 KB
testcase_01 AC 26 ms
23,616 KB
testcase_02 AC 25 ms
23,784 KB
testcase_03 AC 25 ms
23,628 KB
testcase_04 AC 25 ms
23,964 KB
testcase_05 AC 26 ms
24,204 KB
testcase_06 AC 24 ms
23,568 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
23,892 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;
}

int n;
int a[356];

void solve() {
    a[0]=1;
    for(int i=1; i<n; ++i) {
        int l=-1; 
        int r=i;
        while(l+1<r) {
            int mid=(l+r)/2;
            cout<<"? "<<a[mid]<<" "<<i+1<<endl;
            int ret; cin>>ret;
            if(ret==a[mid]) {
                l=mid;
            } else {
                r=mid;
            }
        }
        for(int j=i; j>r; --j) {
            a[j]=a[j-1];
        }
        a[r]=i+1;
    }
    cout<<"! "<<a[1]<<endl;
}

signed main() {
    //ios_untie();
#ifdef LOCAL
    file_setup();
#endif

    cin>>n;
    solve();
}
0