結果

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

テストケース

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

ソースコード

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=n;i>=1;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