結果

問題 No.2124 Guess the Permutation
ユーザー _yurimoir
提出日時 2022-11-19 06:56:25
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 2,827 ms
コンパイル使用メモリ 245,544 KB
実行使用メモリ 25,220 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-09-20 09:16:04
合計ジャッジ時間 4,181 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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