#include #include #include #include using namespace std; int N; int ask(const vector& a) { cout << "?"; for (int x : a) { cout << " " << x; } cout << "\n"; cout.flush(); int res; cin >> res; if (res == -1) exit(0); return res; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N; int p1 = -1; for (int x = 1; x < N; ++x) { vector a(N, 1); a[x - 1] = 2; int lis = ask(a); if (lis == 1) { p1 = x; break; } } if (p1 == -1) { p1 = N; } vector rem; for (int i = 1; i <= N; ++i) { if (i != p1) rem.push_back(i); } auto cmp = [&](int x, int y) { vector a(N, 0); a[x - 1] = 1; a[y - 1] = 2; int lis = ask(a); return lis == 3; }; stable_sort(rem.begin(), rem.end(), cmp); cout << "! " << p1; for (int x : rem) { cout << " " << x; } cout << "\n"; cout.flush(); return 0; }