#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?a:b);
}
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())];
}
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);
for(int i=0;i<(int)tmp2.size()-1;i++){
Bridge(tmp2[i],tmp2[i+1]);
}
p[root].push_back(root);
p[x].push_back(x);
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
712 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |