結果

問題 No.2124 Guess the Permutation
ユーザー mikammikam
提出日時 2022-11-19 16:24:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 203,548 KB
実行使用メモリ 24,684 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 20:35:17
合計ジャッジ時間 3,254 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi = vector<int>;
template<typename T1,typename T2> bool chmax(T1 &a, const T2 b) {if (a < b) {a = b; return true;} else return false; }
template<typename T1,typename T2> bool chmin(T1 &a, const T2 b) {if (a > b) {a = b; return true;} else return false; }

signed main() {

    int n;cin>>n;
    int sum = 0;
    for(int i=1;i<=n;i++)sum+=i;
    int Sum = sum;

    vi p(n);
    for(int r=n-1;r>1;r--){
        cout<<"? 1 "<<r<<endl;
        int s;cin>>s;
        p[r] = sum-s;
        sum-=p[r];
    }
    cout<<"? 2 "<<n<<endl;
    int s;cin>>s;
    p[0] = Sum-s;
    p[1] = sum-p[0];
    cout<<"! ";
    rep(i,n)cout << p[i] << " \n"[i==n-1];
    return 0;
}
0