結果

問題 No.2124 Guess the Permutation
ユーザー KKT89KKT89
提出日時 2022-11-18 21:31:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 133,156 KB
実行使用メモリ 24,576 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 06:17:58
合計ジャッジ時間 2,648 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int sum = (1+n)*n/2;
    vector<int> a(n);
    cout << "? " << 1 << " " << n-1 << endl;
    int r; cin >> r;
    a.back() = sum-r;
    int pre = a.back();
    sum = r;
    for(int i=n-2;i>0;i--){
        cout << "? " << i+1 << " " << n << endl;
        cin >> r;
        a[i] = r-pre;
        pre = r;
        sum -= a[i];
    }
    a[0] = sum;
    cout << "!";
    for(int i=0;i<n;i++){
        cout << " " << a[i];
    }
    cout << endl;
}
0