# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
312575 | mohamedsobhi777 | Mouse (info1cup19_mouse) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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" ;
}*/
}