#include #include using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 vector a; int N; pair calc(int a,int b){ int x = a/N - b/N; int y = a%N - b%N; if(x>y)swap(x,y); return make_pair(x,y); } pair query(int i,int j){ cout<<"? "<>r0>>r1; return make_pair(r0,r1); } void answer(vector ans){ cout<<"!"; rep(i,ans.size()){ cout<<' '< ans(N*N-N,-1); vector> ret; rep(i,ans.size()){ if(i==0)continue; ret.push_back(query(1,i+1)); } { vector> temp = ret; sort(temp.begin(),temp.end()); rep(i,N*N-N){ vector> X; rep(j,N*N-N){ if(i==j)continue; X.push_back(calc(i+N,j+N)); } sort(X.begin(),X.end()); if(X==temp){ ans[0] = i+N; break; } } } map> mp; rep(i,ret.size()){ rep(j,N*N-N){ if(ret[i]==calc(ans[0],j+N)){ mp[j+N].push_back(i+1); break; } } } while(mp.size()!=0){ for(auto it = mp.begin();it!=mp.end();){ if(it->second.size()==1){ ans[it->second[0]] = it->first; it = mp.erase(it); } else{ int x = it->first; int y; for(int i=x+1;i ret = query(i+1,it->second[0]+1); if(ret==calc(ans[i],x)){ ans[it->second[0]] = x; ans[it->second[1]] = y; } else{ ans[it->second[0]] = y; ans[it->second[1]] = x; } f=true; break; } } if(f){ it = mp.erase(it); } else{ it++; } } } } answer(ans); } int main(){ cin>>N; /* a.resize(N*N-N); rep(i,N*N-N){ cin>>a[i]; } */ solve(); return 0; }