제출 #934888

#제출 시각아이디문제언어결과실행 시간메모리
934888Darren0724Meetings (JOI19_meetings)C++17
100 / 100
835 ms3184 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; mt19937 rnd(time(0)); const int N=2005; int n; void ans(int a,int b){ if(a>b)swap(a,b); Bridge(a,b); } void dfs(int k,vector<int> &r){ int sz=r.size(); if(sz==0)return; int k1=r[rnd()%sz]; vector<int> rec(n),adj[n]; vector<int> path; for(int j:r){ if(j==k1)continue; int lca=Query(k,k1,j); if(lca==j){ rec[j]=1; path.push_back(j); } else{ adj[lca].push_back(j); } } sort(path.begin(),path.end(),[&](int a,int b){return Query(k,a,b)==a;}); path.push_back(k1); int last=k; for(int j:path){ ans(last,j); last=j; } for(int j:path){ dfs(j,adj[j]); } dfs(k,adj[k]); } void Solve(int n1) { n=n1; int k=rnd()%n; vector<int> t; for(int i=0;i<n;i++){ if(i!=k)t.push_back(i); } dfs(k,t); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...