結果

問題 No.2124 Guess the Permutation
ユーザー Fu_LFu_L
提出日時 2024-03-04 00:08:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 204,096 KB
実行使用メモリ 24,012 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-03-04 00:08:40
合計ジャッジ時間 3,712 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    int n;
    cin >> n;
    vector<int> p(n);
    int sum = n * (n + 1) / 2;
    rep(i, 1, n - 1) {
        cout << "? " << i + 1 << ' ' << n << endl;
        int s;
        cin >> s;
        p[i - 1] = sum - s;
        sum -= p[i - 1];
    }
    cout << "? " << 1 << ' ' << n - 1 << endl;
    int s;
    cin >> s;
    p[n - 1] = n * (n + 1) / 2 - s;
    int cnt = 0;
    rep(i, 0, n) cnt += p[i];
    p[n - 2] = n * (n + 1) / 2 - cnt;
    cout << "! ";
    rep(i, 0, n) {
        cout << p[i] << ' ';
    }
    cout << endl;
}
0