Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- #define all(x) x.begin(), x.end()
- #define rall(x) x.rbegin(), x.rend()
- //#define endl '\n'
- #define boostIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
- vector<int> inv(vector<int> A) {
- vector<int> B(A.size());
- for (int i = 1; i <= A.size(); ++i) {
- B[A[i - 1] - 1] = i;
- }
- return B;
- }
- signed main() {
- auto p = inv({ 3, 2, 1});
- //auto s = inv({ 2, 4, 3, 1 });
- int q;
- cin >> q;
- while (q--) {
- int n;
- cin >> n;
- cout << "? ";
- for (int i = 0; i < n; ++i) {
- cout << 1 + (i + 1) % n << " ";
- }
- cout << endl;
- vector<int> ans(n), res(n);
- for (auto& x : ans) cin >> x;
- for (int i = 0; i < n; ++i) {
- res[i] = ans[(2 * n - 2 - n % 2 - i) % n];
- }
- ans = inv(res);
- cout << "! ";
- for (auto x : ans) cout << x << " ";
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment