結果

問題 No.850 企業コンテスト2位
ユーザー chocoruskchocorusk
提出日時 2019-03-23 02:44:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,715 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 97,688 KB
実行使用メモリ 24,456 KB
平均クエリ数 291.29
最終ジャッジ日時 2023-09-23 16:50:29
合計ジャッジ時間 5,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,352 KB
testcase_01 AC 24 ms
23,676 KB
testcase_02 AC 24 ms
23,604 KB
testcase_03 AC 24 ms
24,288 KB
testcase_04 AC 24 ms
23,988 KB
testcase_05 AC 24 ms
23,616 KB
testcase_06 AC 24 ms
23,472 KB
testcase_07 AC 29 ms
23,376 KB
testcase_08 AC 32 ms
23,436 KB
testcase_09 AC 32 ms
23,880 KB
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
24,348 KB
権限があれば一括ダウンロードができます

ソースコード

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 mx1=1, mx2=n/2+1;
    for(int i=2; i<=n/2; i++){
        cout<<"? "<<mx1<<" "<<i<<endl;
        cin>>ret;
        if(ret==i){
            mx1=i;
        }
    }
    for(int i=n/2+2; i<=n; i++){
        cout<<"? "<<mx2<<" "<<i<<endl;
        cin>>ret;
        if(ret==i){
            mx2=i;
        }
    }
    cout<<"? "<<mx1<<" "<<mx2<<endl;
    cin>>ret;
    int ans;
    if(ret==mx1){
        if(n/2==1){
            cout<<"! "<<mx2<<endl; return 0;
        }
        ans=1;
        if(ans==mx1) ans=2;
        for(int i=2; i<=n/2; i++){
            if(i==mx1 || ans==i) continue;
            cout<<"? "<<i<<" "<<ans<<endl;
            cin>>ret;
            if(ret==i) ans=i;
        }
        cout<<"? "<<ans<<" "<<mx2<<endl;
        cin>>ret;
        cout<<"! "<<ret<<endl;
    }else{
        if(n-n/2==1){
            cout<<"! "<<mx1<<endl; return 0;
        }
        ans=n/2+1;
        if(ans==mx2) ans=n/2+2;
        for(int i=n/2+2; i<=n; i++){
            if(i==mx2 || ans==i) continue;
            cout<<"? "<<i<<" "<<ans<<endl;
            cin>>ret;
            if(ret==i) ans=i;
        }
        cout<<"? "<<ans<<" "<<mx1<<endl;
        cin>>ret;
        cout<<"! "<<ret<<endl;
    }
    return 0;
}
0