結果

問題 No.850 企業コンテスト2位
ユーザー chocoruskchocorusk
提出日時 2019-03-23 03:15:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,250 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 96,252 KB
実行使用メモリ 24,540 KB
平均クエリ数 231.75
最終ジャッジ日時 2023-09-23 16:51:09
合計ジャッジ時間 5,381 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,964 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 25 ms
23,436 KB
testcase_06 WA -
testcase_07 AC 30 ms
23,352 KB
testcase_08 AC 32 ms
23,304 KB
testcase_09 AC 32 ms
23,772 KB
testcase_10 AC 37 ms
23,472 KB
testcase_11 AC 34 ms
24,072 KB
testcase_12 AC 35 ms
24,048 KB
testcase_13 AC 35 ms
23,904 KB
testcase_14 AC 34 ms
23,976 KB
testcase_15 AC 32 ms
23,604 KB
testcase_16 WA -
testcase_17 AC 35 ms
23,352 KB
testcase_18 AC 34 ms
23,316 KB
testcase_19 AC 35 ms
23,448 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int ret;
    int b[200];
    for(int i=1; i<=n/2; i++){
        cout<<"? "<<2*i<<" "<<2*i-1<<endl;
        cin>>ret;
        b[i]=ret;
    }
    if(n&1) b[n/2+1]=n;
    int mx=b[1], mx2=b[2];
    cout<<"? "<<b[1]<<" "<<b[2]<<endl;
    cin>>ret;
    if(ret==b[2]) swap(mx, mx2);
    for(int i=3; i<=(n+1)/2; i++){
        cout<<"? "<<mx2<<" "<<b[i]<<endl;
        cin>>ret;
        if(ret==mx2) continue;
        cout<<"? "<<mx<<" "<<b[i]<<endl;
        cin>>ret;
        if(ret==mx){
            mx2=b[i];
        }else{
            mx2=mx;
            mx=b[i];
        }
    }
    if((n&1) && mx==n){
        cout<<"! "<<mx2<<endl;
    }else{
        int x=(mx+1)/2*4-1-mx;
        cout<<"? "<<mx2<<" "<<x<<endl;
        cout<<"! "<<ret<<endl;
    }
    return 0;
}
0