제출 #249456

#제출 시각아이디문제언어결과실행 시간메모리
249456dantoh000Meetings (JOI19_meetings)C++14
7 / 100
2462 ms760 KiB
#include <bits/stdc++.h> #include "meetings.h" int col[2005]; int n; using namespace std; void solve(int id){ /*printf("solving "); for (auto x : v) printf("%d ",x); printf("\n");*/ vector<int> v; for (int i = 0; i < n; i++){ if (col[i] == id) v.push_back(i); } 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); for (auto x : v){ if (x == q || x == p) continue; int Q = Query(p,q,x); if (Q == p) col[x] = 2*id; else col[x] = 2*id+1; } col[p] = 2*id; col[q] = 2*id+1; solve(2*id); solve(2*id+1); } void Solve(int N) { n = N; for (int i = 0; i < N; i++) col[i] = 1; solve(1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...