結果
| 問題 | 
                            No.2124 Guess the Permutation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-02-05 13:40:40 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 76 ms / 2,000 ms | 
| コード長 | 763 bytes | 
| コンパイル時間 | 4,012 ms | 
| コンパイル使用メモリ | 276,336 KB | 
| 実行使用メモリ | 25,844 KB | 
| 平均クエリ数 | 374.60 | 
| 最終ジャッジ日時 | 2025-02-05 13:40:52 | 
| 合計ジャッジ時間 | 6,105 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 9 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define all(a) (a).begin(),(a).end()
int main() {
    int N;
    cin >> N;
    
    vector<int> ans;
    
    int allSum = N*(N + 1) / 2;
    int guessSum = 0;
    
    rep(i, 0, N - 2) {
        cout << "? " << i + 2 << " " << N << '\n';
        
        int S;
        cin >> S;
        
        ans.push_back(allSum - S - guessSum);
        guessSum += ans.back();
    }
    
    cout << "? 1 " << N - 1 << '\n';
    int S;
    cin >> S;
    ans.push_back(S - guessSum);
    guessSum += ans.back();
    
    ans.push_back(allSum - guessSum);
    
    cout << "! ";
    rep(i, 0, N) cout << ans[i] << (i == N - 1 ? '\n' : ' ');
}