#include #include #include #include #define MAXN 100000 #define rep(E, F) for (E = 0; E < (F); E++) int min(int a, int b) { if (a > b) return b; return a; } int max(int a, int b) { if (a < b) return b; return a; } int get_int() { int r = 0, c = getchar(), s = 1; while (c != '-' && c < '0' || c > '9') c = getchar(); while (c == '-') s *= -1, c = getchar(); while (c >= '0' && c <= '9') r = r*10 + c - '0', c = getchar(); return s*r; } void query(int x, int y, int *xx, int *yy) { printf("? %d %d\n", x + 1, y + 1); fflush(stdout); *xx = get_int(), *yy = get_int(); } void shuffle(int* a, int n, int m) { int i, j, s; rep(i, m) { j = rand()%(n - i); s = a[j]; a[j] = a[n - 1 - i]; a[n - 1 - i] = s; } } int main() { srand(10); int i, x, y, n = get_int(), m = n, a[n], b[n]; rep(i, n) a[i] = i, b[i] = -1; shuffle(a, n, n); while (m > 0) { shuffle(a, m, 2); query(a[m - 1], a[m - 2], &x, &y); if (x == y) b[a[m - 1]] = x, b[a[m - 2]] = y, m -= 2; } printf("!"); rep(i, n) printf(" %d", b[i]); printf("\n"); fflush(stdout); return 0; }