Submission #249453

#TimeUsernameProblemLanguageResultExecution timeMemory
249453dantoh000Meetings (JOI19_meetings)C++14
29 / 100
2635 ms904 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; void solve(vector<int> v){ /*printf("solving "); for (auto x : v) printf("%d ",x); printf("\n");*/ if (v.size() == 1) return; if (v.size() == 2){ if (v[0] > v[1]) swap(v[0],v[1]); Bridge(v[0],v[1]); return; } random_shuffle(v.begin(),v.end()); int p = v[0], q = v[1]; //printf("cur %d, root %d\n",cur,root); for (auto x : v){ if (x == p || x == q) continue; int Q = Query(p,q,x); if (Q != p) q = Q; } //printf("cur %d, root %d\n",cur,root); if (p > q) swap(p,q); Bridge(p,q); vector<int> L, R; for (auto x : v){ if (x == q || x == p) continue; int Q = Query(p,q,x); assert(Q == p || Q == q); if (Q == p) R.push_back(x); else L.push_back(x); } L.push_back(q); R.push_back(p); solve(L); solve(R); } void Solve(int N) { vector<int> cur; for (int i = 0; i < N; i++) cur.push_back(i); solve(cur); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...