#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; #ifndef ONLINE_JUDGE constexpr int N = 500; bool has_edge[N][N]{}; int q = 0; #endif bool query(const int a, const int b) { #ifndef ONLINE_JUDGE ++q; return has_edge[a][b]; #else cout << "? " << a + 1 << ' ' << b + 1 << endl; int t; cin >> t; assert(t != -1); return t == 1; #endif } int main() { int n; cin >> n; #ifndef ONLINE_JUDGE int m; cin >> m; assert(n * (n - 1) / 2 == m); while (m--) { int a, b; cin >> a >> b; --a; --b; has_edge[a][b] = true; } #endif vector c(n); iota(ALL(c), 0); const auto merge_sort = [&](auto&& merge_sort, const int l, const int r) -> void { if (l + 1 == r) return; const int m = (l + r) / 2; merge_sort(merge_sort, l, m); merge_sort(merge_sort, m, r); vector a; a.reserve(r - l); int i = l, j = m; while (i < m && j < r) a.emplace_back(c[(query(c[i], c[j]) ? i : j)++]); for (; i < m; ++i) { a.emplace_back(c[i]); } for (; j < r; ++j) { a.emplace_back(c[j]); } copy(ALL(a), c.begin() + l); }; merge_sort(merge_sort, 0, n); #ifndef ONLINE_JUDGE cout << "query: " << q << '\n'; #endif cout << "!\n" << n - 1 << '\n'; REP(i, n) { cout << c[i] + 1; if (i + 1 == n) { cout << endl; } else { cout << ' '; } } return 0; }