#include #include #include using namespace std; using BI = vector; constexpr int LGN = 9; BI add(const BI &a, const BI &b) { BI c(a.size()); int q = 0; for (int i = 1; i < (int)a.size(); i++) { c[i] = a[i] + b[i] + q; q = c[i] >= i; c[i] = c[i] >= i ? c[i] - i : c[i]; } return c; } BI div2(const BI &a) { BI b(a.size()); int q = 0; for (int i = (int)a.size() - 1; i >= 1; i--) { q = q * i + a[i]; b[i] = q / 2; q %= 2; } return b; } bool gr(const BI &a, const BI &b) { for (int i = (int)a.size() - 1; i >= 1; i--) { if (a[i] != b[i]) { return a[i] > b[i]; } } return false; } void add(int bit[], int n, int x, int a) { for (; x <= n; x += x & -x) { bit[x] += a; } } int qry(int bit[], int n, int v) { int x = 0, cur = 0; for (int i = LGN - 1; i >= 0; i--) { if (x + (1 << i) <= n) { if (cur + bit[x+(1<> n; BI l(n + 2), r(n + 2); r[n+1] = 1; BI one(n + 2); one[2] = 1; while (gr(r, add(l, one))) { BI mid = div2(add(l, r)); int q[n]; find_perm(mid, n, q); cout << "?"; for (int i = 0; i < n; i++) { cout << " " << q[i]; } cout << endl; int res; cin >> res; if (res == 1) { l = mid; } else { r = mid; } } int ans[n]; find_perm(l, n, ans); cout << "!"; for (int i = 0; i < n; i++) { cout << " " << ans[i]; } cout << endl; return 0; }