結果

問題 No.3590 I Love Inversions
コンテスト
ユーザー t98slider
提出日時 2026-07-17 22:23:58
言語 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
結果
RE  
実行時間 -
コード長 602 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,065 ms
コンパイル使用メモリ 335,176 KB
実行使用メモリ 5,888 KB
平均クエリ数 1202.95
最終ジャッジ日時 2026-07-17 22:24:16
合計ジャッジ時間 16,304 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 2 RE * 33
権限があれば一括ダウンロードができます

ソースコード

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){
        int res;
        cout << "? " << l + 1 << " " << r + 1 << endl;
        cin >> res;
        return res;
    };
    vector<int> a = {0};
    for(int i = 1; i < N; i++){
        a.insert(a.begin() + (i - ask(0, i)), i);
    }
    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