結果

問題 No.2124 Guess the Permutation
ユーザー _yurimoir_yurimoir
提出日時 2022-11-19 06:56:25
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 2,721 ms
コンパイル使用メモリ 246,716 KB
実行使用メモリ 24,660 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 13:45:04
合計ジャッジ時間 5,653 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,660 KB
testcase_01 AC 24 ms
24,660 KB
testcase_02 AC 24 ms
24,660 KB
testcase_03 AC 24 ms
24,660 KB
testcase_04 AC 24 ms
24,660 KB
testcase_05 AC 27 ms
24,660 KB
testcase_06 AC 41 ms
24,660 KB
testcase_07 AC 56 ms
24,660 KB
testcase_08 AC 56 ms
24,660 KB
testcase_09 AC 55 ms
24,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<"? 2 "<<n<<endl<<flush;
    int p1n;
    cin>>p1n;
    vector<int> p(n);
    p[0]=n*(n+1)/2-p1n;
    int sum=p[0];
    for(int i=2;i<=n-1;i++){
        cout<<"? "<<i-1<<" "<<i<<endl<<flush;
        int ss;
        cin>>ss;
        p[i-1]=ss-p[i-2];
        sum+=p[i-1];
    }
    p[n-1]=n*(n+1)/2-sum;
    cout<<"! ";
    for(int i=0;i<n;i++)cout<<p[i]<<" ";
    cout<<endl<<flush;
    return 0;
}
0