이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
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... |