이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
mt19937 rng(time(NULL));
int gen(int x){
return abs((int)rng())%x;
}
int R;
int n;
bool comp(int a,int b){
return Query(R,a,b)==a;
}
void go(int root,vector<int> vec){
if((int)vec.size()==1) return;
vector<vector<int>> p(n);
int x=vec[gen((int)vec.size())];
while(x==root){
x=vec[gen((int)vec.size())];
}
//cout<<root<<' '<<x<<'\n';
for(auto v:vec){
if(v==x or v==root) continue;
int q=Query(root,v,x);
p[q].push_back(v);
}
vector<int> tmp;
for(auto v:vec){
if(v==root or v==x or p[v].empty()) continue;
tmp.push_back(v);
}
R=root;
sort(all(tmp),comp);
vector<int> tmp2;
tmp2.push_back(root);
tmp2.insert(tmp2.end(),all(tmp));
tmp2.push_back(x);
/*cout<<"list: ";
for(auto v:tmp2){
cout<<v<<' ';
}
cout<<'\n';*/
for(int i=0;i<(int)tmp2.size()-1;i++){
Bridge(min(tmp2[i],tmp2[i+1]),max(tmp2[i],tmp2[i+1]));
}
p[root].push_back(root);
p[x].push_back(x);
/*cout<<"check"<<'\n';
for(auto v:tmp2){
cout<<v<<'\n';
for(auto u:p[v]){
cout<<u<<' ';
}
cout<<'\n';
}
cout<<'\n';*/
for(auto v:tmp2){
go(v,p[v]);
}
}
void Solve(int N){
n=N;
vector<int> vec(n);
for(int i=0;i<n;i++){
vec[i]=i;
}
go(0,vec);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |