제출 #154946

#제출 시각아이디문제언어결과실행 시간메모리
154946MercenaryMeetings (JOI19_meetings)C++14
0 / 100
17 ms16248 KiB
#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)return u; 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){ 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) { memset(L,-1,sizeof L); vector<int> v(n); for(int i = 0 ; i < n ; ++i)v[i] = i; Solve(v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...