#include "grader.h"
#include<bits/stdc++.h>
using namespace std ;
int n, num ;
vector<int> per, ans ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> cand[N] ;
void solve2(int n){
vector<pair<int,int> > gp ;
for(int i = 0 ;i < n; ++ i)ans.push_back(i + 1) ;
while(query(ans))
random_shuffle(ans.begin() , ans.end()) ;
for(int i = 0 ;i < n; ++ i){
for(int j = i + 1; j < n; ++ j){
swap(ans[i] , ans[j]) ;
if(query(ans))
gp.push_back({i , j}) ;
swap(ans[i] , ans[j]) ;
}
}
for(auto u : gp){
int a = u.first ;
int b = u.second ;
cand[a].push_back(ans[b]) ;
cand[b].push_back(ans[a]) ;
}
int gud = 0 ;
for(int i = 1 ; i < n; ++ i){
swap(ans[i] , ans[0]) ;
if(query(ans) == 2)
break ;
if(query(ans) == 1){
swap(ans[0] , ans[1]) ;
if(query(ans)){
gud = i ;
}else{
gud = 0 ;
}
swap(ans[0], ans[1]) ;
}
}
vector<int> ve ;
for(int i = 0 ; i < n ; ++ i){
if(i == gud)continue ;
ve.push_back(i) ;
}
while(query(ans) > 1){
int j = 0 ;
vector<int> nw ;
random_shuffle(ve.begin() , ve.end()) ;
for(int i = 0 ;i < n ; ++ i){
if(i == gud)
nw.push_back(ans[gud]) ;
else
nw.push_back(ans[ve[j++]]) ;
}
ans = nw ;
}
//for(int i = 0 ;i < n; ++ i)
// cout<< ans[i] <<" " ;
// cout<<"***\n" ;
// exit(0) ;
map<int,int> pl ;
for(int i = 0 ; i < n; ++ i)
pl[ans[i]] = i ;
vector<int> ret(n , 0) ;
ret[gud] = ans[gud] ;
for(int i = 0;i < n; ++ i){
if(i == gud)continue ;
for(auto u : cand[i]){
//cout<< i <<" "<< u <<" "<< ans[gud] <<"*(\n" ;
if(ans[i] == u || u == ans[gud])
continue ;
vector<int> qu = ans ;
int j = pl[u] ;
qu[gud] = ans[i] ;
qu[i] = ans[j] ;
qu[j] = ans[gud] ;
for(int r = 0 ; r < n ; ++ r){
// cout<< qu[r] <<" " ;
}
if(query(qu) == 1){
ret[i] = u ;
break ;
}
}
}
query(ret) ;
return ;
// for(auto u : ret)
// cout<< u <<" " ;
if(query(ret) != n){
cout<<"incorrect" ;
exit(0) ;
}
/*
for(int i = 0 ;i < n; ++ i){
cout<< i <<" : " ;
for(auto u : cand[i])
cout<< u <<" " ;
cout<<"...\n" ;
}*/
}
Compilation message
mouse.cpp:8:18: error: 'N' was not declared in this scope
8 | vector<int> cand[N] ;
| ^
mouse.cpp: In function 'void solve2(int)':
mouse.cpp:26:25: error: 'cand' was not declared in this scope; did you mean 'rand'?
26 | cand[a].push_back(ans[b]) ;
| ^~~~
| rand
mouse.cpp:77:38: error: 'cand' was not declared in this scope; did you mean 'rand'?
77 | for(auto u : cand[i]){
| ^~~~
| rand