Submission #249458

#TimeUsernameProblemLanguageResultExecution timeMemory
249458dantoh000Meetings (JOI19_meetings)C++14
29 / 100
2808 ms848 KiB
#include <bits/stdc++.h> #include "meetings.h" int col[2005]; int n; using namespace std; void solve(int id, int sz){ if (sz == 1) return; vector<int> v(sz); int ct = 0; for (int i = 0; i < n; i++){ if (col[i] == id) v[ct++] = i; if (sz == 2 && ct == 2){ if (v[0] > v[1]) swap(v[0],v[1]); Bridge(v[0],v[1]); return; } } /*printf("solving "); for (auto x : v) printf("%d ",x); printf("\n");*/ 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); int lct = 1, rct = 1; for (auto x : v){ if (x == q || x == p) continue; int Q = Query(p,q,x); if (Q == p) {col[x] = 2*id; lct++;} else {col[x] = 2*id+1; rct++;} } col[p] = 2*id; col[q] = 2*id+1; solve(2*id,lct); solve(2*id+1,rct); } void Solve(int N) { n = N; for (int i = 0; i < N; i++) col[i] = 1; solve(1,n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...