Georgiy031

Untitled

Nov 22nd, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. typedef unsigned long long ull;
  6. #define all(x) x.begin(), x.end()
  7. #define rall(x) x.rbegin(), x.rend()
  8. //#define endl '\n'
  9. #define boostIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  10. ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
  11.  
  12. vector<int> inv(vector<int> A) {
  13.     vector<int> B(A.size());
  14.     for (int i = 1; i <= A.size(); ++i) {
  15.         B[A[i - 1] - 1] = i;
  16.     }
  17.     return B;
  18. }
  19.  
  20. signed main() {
  21.     auto p = inv({ 3, 2, 1});
  22.     //auto s = inv({ 2, 4, 3, 1 });
  23.     int q;
  24.     cin >> q;
  25.     while (q--) {
  26.         int n;
  27.         cin >> n;
  28.         cout << "? ";
  29.         for (int i = 0; i < n; ++i) {
  30.             cout << 1 + (i + 1) % n << " ";
  31.         }
  32.         cout << endl;
  33.         vector<int> ans(n), res(n);
  34.         for (auto& x : ans) cin >> x;
  35.  
  36.         for (int i = 0; i < n; ++i) {
  37.             res[i] = ans[(2 * n - 2 - n % 2 - i) % n];
  38.         }
  39.         ans = inv(res);
  40.  
  41.         cout << "! ";
  42.         for (auto x : ans) cout << x << " ";
  43.         cout << endl;
  44.     }
  45.  
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment