#include "meetings.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn = 2e3 + 4;
int L[maxn][maxn];
int LCA(int u , int v){
if(u == 0 || v == 0)return 0;
if(u > v)swap(u , v);
if(L[u][v] == -1)return L[u][v];
return L[u][v] = Query(0 , u , v);
}
void Solve(vector<int> child){
memset(L,-1,sizeof L);
vector<int> v[maxn];
srand(time(0));
int u = child[rand() % child.size()];
vector<int> can;
for(int c : child){
int a = LCA(c , u);
if(a == c){
can.pb(a);
}
v[a].pb(c);
}
sort(can.begin(),can.end(),[&](const int & x , const int & y){
return LCA(x , y) == x;
});
for(int i = 0 ; i < (int)can.size() - 1 ; ++i){
Bridge(min(can[i] , can[i + 1]) , max(can[i] , can[i + 1]));
}
for(int c : child)if(v[c].size() > 1)Solve(v[c]);
}
void Solve(int n) {
vector<int> v(n);
for(int i = 0 ; i < n ; ++i)v[i] = i;
Solve(v);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
16120 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
16120 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
16120 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
16248 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |