結果
| 問題 | 
                            No.2124 Guess the Permutation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             eve__fuyuki
                         | 
                    
| 提出日時 | 2024-05-07 14:32:38 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,264 bytes | 
| コンパイル時間 | 2,332 ms | 
| コンパイル使用メモリ | 203,468 KB | 
| 最終ジャッジ日時 | 2025-02-21 11:35:34 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | WA * 9 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}
bool debug = true;
int n;
vector<int> p, cum;
int cnt = 0;
int query(int l, int r) {
    cout << "? " << l << " " << r << endl;
    cnt++;
    if (debug) {
        return cum[r] - cum[l - 1];
    } else {
        int res;
        cin >> res;
        return res;
    }
}
void answer(vector<int> &a) {
    cout << "! ";
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << " ";
    }
    cout << endl;
    if (debug) {
        assert(a == p);
        assert(cnt < n);
    }
}
int main() {
    fast_io();
    cin >> n;
    if (debug) {
        p.resize(n);
        iota(p.begin(), p.end(), 1);
        shuffle(p.begin(), p.end(), mt19937{random_device{}()});
        cum.resize(n + 1);
        for (int i = 1; i <= n; i++) {
            cum[i] = cum[i - 1] + p[i - 1];
        }
    }
    vector<int> a(n);
    vector<bool> vis(n + 1);
    a[0] = n * (n + 1) / 2 - query(2, n);
    vis[a[0]] = true;
    for (int i = 1; i < n - 1; i++) {
        a[i] = query(i, i + 1) - a[i - 1];
        vis[a[i]] = true;
    }
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            a[n - 1] = i;
        }
    }
    answer(a);
}
            
            
            
        
            
eve__fuyuki