結果

問題 No.3590 I Love Inversions
コンテスト
ユーザー shingo0909
提出日時 2026-07-17 21:35:06
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2,135 ms / 5,000 ms
+ 32µs
コード長 974 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,545 ms
コンパイル使用メモリ 356,932 KB
実行使用メモリ 6,400 KB
平均クエリ数 12104.46
最終ジャッジ日時 2026-07-17 21:35:33
合計ジャッジ時間 26,341 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/extc++.h>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cout << "? " << 1 << " " << i + 1 << endl;
        cin >> a[i];
    }
    for (int i = n - 1; i > 0; i--) {
        a[i] -= a[i - 1];
    }
    // for (int i : a)
    //     cout << i << " ";
    // cout << endl;
    ordered_set<int> s;
    rep(i, n) s.insert(i + 1);
    vector<int> ans(n);
    for (int i = n - 1; i >= 0; i--) {
        int x = *s.find_by_order(s.size() - 1 - a[i]);
        ans[i] = x;
        s.erase(x);
    }
    cout << "!";
    for (int i : ans)
        cout << " " << i;
    cout << endl;
    return 0;
}
0