結果
問題 | No.2124 Guess the Permutation |
ユーザー |
|
提出日時 | 2022-11-18 21:59:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 1,469 ms |
コンパイル使用メモリ | 172,144 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 374.60 |
最終ジャッジ日時 | 2024-09-20 02:21:13 |
合計ジャッジ時間 | 2,611 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ //ios::sync_with_stdio(false); //cin.tie(0); int N, v2 = 0; cin >> N; vector<ll> a(N); vector<bool> used(N, false); for(int i = 1; i + 1 < N; i++){ ll v; cout << "? " << 1 << " " << i + 1 << '\n'; cin >> v; a[i] = v; } a.back() = (ll)(N) * (N + 1) / 2; for(int i = N - 1; i >= 1; i--){ a[i] -= a[i - 1]; used[a[i] - 1] = true; } int v; cout << "? " << 2 << " " << N << '\n'; cin >> v; a[0] = (ll)(N) * (N + 1) / 2 - v; used[a[0] - 1] = true; v = min_element(used.begin(), used.end()) - used.begin(); a[1] = v + 1; cout << "!"; for(int i = 0; i < N; i++){ cout << " " << a[i]; } cout << '\n'; }