結果
問題 |
No.2124 Guess the Permutation
|
ユーザー |
|
提出日時 | 2022-11-18 21:35:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 1,757 ms |
コンパイル使用メモリ | 195,500 KB |
最終ジャッジ日時 | 2025-02-08 21:29:14 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef _RUTHEN #include <debug.hpp> #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template <class T> using V = vector<T>; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; V<int> P(N); int S = N * (N + 1) / 2; for (int i = 2; i < N; i++) { cout << "? " << i << " " << N << endl; int C; cin >> C; P[i - 2] = S - C; S = C; } cout << "? 1 " << N - 1 << endl; int C; cin >> C; int SS = accumulate(P.begin(), P.begin() + N - 2, 0); P[N - 2] = C - SS; P[N - 1] = N * (N + 1) / 2 - accumulate(P.begin(), P.begin() + N - 1, 0); cout << "! "; rep(i, N) cout << P[i] << " \n"[i == N - 1]; return 0; }