제출 #942613

#제출 시각아이디문제언어결과실행 시간메모리
942613yeediotMeetings (JOI19_meetings)C++14
0 / 100
26 ms600 KiB
#include "meetings.h" #include<bits/stdc++.h> using namespace std; mt19937 rng(time(0)); int K; bool cmp(int a,int b){ return Query(K,a,b)==a; } void qq(int a,int b){ if(a>b)swap(a,b); Bridge(a,b); } void go(int k,vector<int>temp){ if(temp.size()==0)return; int n=temp.size(); int k2=rng()%n; K=k; vector<int>child[n],path; for(auto i:temp){ int p=Query(k,k2,i); if(p==i){ path.push_back(i); } else{ child[p].push_back(i); } } sort(path.begin(),path.end(),cmp); for(int i=0;i<n;i++){ if(!i){ qq(k,path[i]); } else{ qq(path[i-1],path[i]); } } go(k,child[k]); for(auto i:path){ go(i,child[i]); } } void Solve(int N){ int n=N; int k=rng()%n; vector<int>temp; for(int i=0;i<n;i++){ if(i!=k)temp.push_back(i); } go(k,temp); } /* input: */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...