/* -*- coding: utf-8 -*- * * 2577.cc: No.2577 Simple Permutation Guess - yukicoder */ #include #include #include #include using namespace std; /* constant */ const int MAX_N = 400; /* typedef */ typedef vector vi; typedef map mvii; /* global variables */ mvii cache; /* subroutines */ int query(vi &as) { auto mit = cache.find(as); if (mit != cache.end()) return mit->second; putchar('?'); for (auto a: as) printf(" %d", a); putchar('\n'); fflush(stdout); int r; scanf("%d", &r); cache[as] = r; return r; } /* main */ int main() { int n; scanf("%d", &n); vi ds(n); for (int i = 0; i < n; i++) ds[i] = i + 1; vi ps(n); for (int i = 0; i < n; i++) { int k0 = 0, k1 = n - i; while (k0 + 1 < k1) { int k = (k0 + k1) / 2; ps[i] = ds[k]; for (int j0 = 0, j1 = i + 1; j0 < n - i; j0++) if (j0 != k) ps[j1++] = ds[j0]; if (query(ps)) k0 = k; else k1 = k; } ps[i] = ds[k0]; ds.erase(ds.begin() + k0); } putchar('!'); for (int i = 0; i < n; i++) printf(" %d", ps[i]); putchar('\n'); fflush(stdout); return 0; }