#include #include using mint = atcoder::static_modint<998244353>; //using mint = atcoder::static_modint<1000000007>; using namespace std; using namespace atcoder; using ld = long double; using ll = long long; #define mp(a,b) make_pair(a,b) #define rep(i,s,n) for(int i=s; i dx{1,0,-1,0},dy{0,1,0,-1}; std::random_device seed_gen; std::mt19937 engine(seed_gen()); int main(){ int n;cin >> n; cout << "? " << 1 << " " << 2 << "\n"; int t;cin >> t; vector a; if(t==1)a={1,2}; else a={2,1}; vector p; rep(i,3,n+1)p.push_back(i); shuffle(p.begin(),p.end(),engine); for(auto i:p){ cout << "? " << i << " " << a[0] << "\n"; cin >> t; if(t==1){ a.insert(a.begin(),i); continue; } cout << "? " << a.back() << " " << i << "\n"; cin >> t; if(t==1){ a.push_back(i); continue; } int l=0,r=a.size()-1; while(r-l>1){ int mid=(r+l)/2; cout << "? " << i << " " << a[mid] << "\n"; cin >> t; if(t==1)r=mid; else l=mid; } a.insert(a.begin()+r,i); } cout << "!\n"; cout << n-1 << "\n"; for(auto x:a)cout << x << " "; }