結果

問題 No.2124 Guess the Permutation
ユーザー _yurimoir_yurimoir
提出日時 2022-11-18 21:32:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 3,774 ms
コンパイル使用メモリ 253,364 KB
実行使用メモリ 24,600 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 06:19:01
合計ジャッジ時間 4,666 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 25 ms
24,576 KB
testcase_02 AC 25 ms
24,576 KB
testcase_03 AC 26 ms
24,576 KB
testcase_04 AC 28 ms
24,576 KB
testcase_05 AC 29 ms
24,576 KB
testcase_06 AC 46 ms
24,576 KB
testcase_07 AC 61 ms
24,576 KB
testcase_08 AC 59 ms
24,576 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> tank(n-1);
    for(int i=0;i<n-1;i++){
        cout<<"? "<<i+1<<" "<<i+2<<endl<<flush;
        cin>>tank[i];
    }
    for(int i=1;i<=n;i++){
        vector<int> ret={i};
        int val=i;
        for(int j=0;j<n-1;j++){
            val=tank[j]-val;
            ret.push_back(val);
        }
        set<int> jdg;
        bool flg=true;
        for(int j=0;j<n;j++){
            jdg.insert(ret[j]);
            if(ret[j]<0||ret[j]>n){
                flg=false;
                break;
            }
        }
        if((int)jdg.size()!=n){
            flg=false;
        }
        if(flg){
            cout<<"! ";
            for(int j=0;j<n;j++)cout<<ret[j]<<" ";
            cout<<endl<<flush;
            return 0;
        }
    }
}
0