結果

問題 No.3590 I Love Inversions
コンテスト
ユーザー t98slider
提出日時 2026-07-17 22:27:50
言語 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,153 ms / 5,000 ms
+ 31µs
コード長 659 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,044 ms
コンパイル使用メモリ 339,740 KB
実行使用メモリ 5,888 KB
平均クエリ数 12103.46
最終ジャッジ日時 2026-07-17 22:28:33
合計ジャッジ時間 25,052 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    auto ask = [&](int l, int r){
        ll res;
        cout << "? " << l + 1 << " " << r + 1 << endl;
        cin >> res;
        return res;
    };
    vector<int> a = {0};
    ll prv = 0;
    for(int i = 1; i < N; i++){
        ll v = ask(0, i);
        a.insert(a.begin() + (i - (v - prv)), i);
        prv = v;
    }
    vector<int> ans(N);
    for(int i = 0; i < N; i++) ans[a[i]] = i + 1;
    cout << "!";
    for(int i = 0; i < N; i++){
        cout << ' ' << ans[i];
    }
    cout << endl;
}
0