結果

問題 No.850 企業コンテスト2位
ユーザー chocoruskchocorusk
提出日時 2019-03-22 01:24:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 878 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 95,372 KB
実行使用メモリ 24,492 KB
平均クエリ数 387.57
最終ジャッジ日時 2023-09-23 16:49:28
合計ジャッジ時間 7,459 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,436 KB
testcase_01 AC 25 ms
23,412 KB
testcase_02 AC 25 ms
23,436 KB
testcase_03 AC 25 ms
23,400 KB
testcase_04 AC 25 ms
23,892 KB
testcase_05 AC 25 ms
24,012 KB
testcase_06 AC 26 ms
24,024 KB
testcase_07 AC 33 ms
23,436 KB
testcase_08 AC 37 ms
23,856 KB
testcase_09 AC 37 ms
23,892 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 25 ms
23,880 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 mx=1;
    for(int i=2; i<=n; i++){
        cout<<"? "<<i<<" "<<mx<<endl;
        int ret;
        cin>>ret;
        if(ret==i) mx=i;
    }
    int ans=1;
    if(mx==1) ans=2;
    for(int i=1; i<=n; i++){
        if(i==mx || i==ans) continue;
        cout<<"? "<<i<<" "<<ans<<endl;
        int ret;
        cin>>ret;
        if(ret==i) ans=i;
    }
    cout<<"! "<<ans<<endl;
    return 0;
}
0