제출 #917156

#제출 시각아이디문제언어결과실행 시간메모리
917156guagua0407Meetings (JOI19_meetings)C++17
100 / 100
868 ms2680 KiB
#include "meetings.h" #include<bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() mt19937 rng(time(NULL)); int gen(int x){ return abs((int)rng())%x; } int R; int n; bool comp(int a,int b){ return Query(R,a,b)==a; } void go(int root,vector<int> vec){ if((int)vec.size()==1) return; vector<vector<int>> p(n); int x=vec[gen((int)vec.size())]; while(x==root){ x=vec[gen((int)vec.size())]; } //cout<<root<<' '<<x<<'\n'; for(auto v:vec){ if(v==x or v==root) continue; int q=Query(root,v,x); p[q].push_back(v); } vector<int> tmp; for(auto v:vec){ if(v==root or v==x or p[v].empty()) continue; tmp.push_back(v); } R=root; sort(all(tmp),comp); vector<int> tmp2; tmp2.push_back(root); tmp2.insert(tmp2.end(),all(tmp)); tmp2.push_back(x); /*cout<<"list: "; for(auto v:tmp2){ cout<<v<<' '; } cout<<'\n';*/ for(int i=0;i<(int)tmp2.size()-1;i++){ Bridge(min(tmp2[i],tmp2[i+1]),max(tmp2[i],tmp2[i+1])); } p[root].push_back(root); p[x].push_back(x); /*cout<<"check"<<'\n'; for(auto v:tmp2){ cout<<v<<'\n'; for(auto u:p[v]){ cout<<u<<' '; } cout<<'\n'; } cout<<'\n';*/ for(auto v:tmp2){ go(v,p[v]); } } void Solve(int N){ n=N; vector<int> vec(n); for(int i=0;i<n;i++){ vec[i]=i; } go(0,vec); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...