Submission #249455

#TimeUsernameProblemLanguageResultExecution timeMemory
249455dantoh000Meetings (JOI19_meetings)C++14
29 / 100
2479 ms1036 KiB
#include <bits/stdc++.h> #include "meetings.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; } 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...