結果
| 問題 |
No.2124 Guess the Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-18 21:32:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 1,324 bytes |
| コンパイル時間 | 1,561 ms |
| コンパイル使用メモリ | 172,208 KB |
| 実行使用メモリ | 24,964 KB |
| 平均クエリ数 | 374.60 |
| 最終ジャッジ日時 | 2024-09-20 01:57:04 |
| 合計ジャッジ時間 | 2,650 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T = int> using V = vector<T>;
template <class T = int> using VV = vector<V<T>>;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " ";} std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define rep(i, n) for(int i = 0; i < (int) n; i++)
int main() {
int n;
cin >> n;
V<> ans(n);
cout << "? " << 2 << " " << n << endl;
int x;
cin >> x;
ans[0] = n * (n + 1) / 2 - x;
for (int i = 0; i < n - 2; i++) {
cout << "? " << i + 1 << " " << i + 2 << endl;
int r;
cin >> r;
ans[i + 1] = r - ans[i];
}
V<bool> used(n, false);
for (int i = 0; i < n - 1; i++) {
used[ans[i] - 1] = true;
}
for (int i = 0; i < n; i++) {
if (!used[i]) ans[n - 1] = i + 1;
}
cout << "! ";
for (int i = 0; i < n; i++) {
cout << ans[i] << " ";
}
cout << endl;
}