Submission #374956

#TimeUsernameProblemLanguageResultExecution timeMemory
374956BartolMMeetings (JOI19_meetings)C++17
29 / 100
2878 ms1580 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; typedef pair <ll, ll> pll; const int INF=0x3f3f3f3f; int n; void upit(int x, int y) { Bridge(min(x, y), max(x, y)); } void rek(vector <int> v) { if (v.size()==1) return; if (v.size()==2) { upit(v[0], v[1]); return; } int uk=0; vector <int> nv[18]; int koji[18]; int cent=v[rand()%(int)v.size()]; #if DEBUG printf("cent: %d\n", cent); for (int x:v) printf("%d ", x); printf("\n"); #endif // DEBUG for (int x:v) { if (x==cent) continue; int fl=0; for (int i=0; i<uk; ++i) { int y=Query(cent, koji[i], x); if (y==cent) continue; nv[i].pb(x); fl=1; if (y==x) koji[i]=x; break; } if (!fl) { nv[uk].pb(x); koji[uk++]=x; } } for (int i=0; i<uk; ++i) upit(cent, koji[i]); for (int i=0; i<uk; ++i) rek(nv[i]); } void Solve(int nn) { n=nn; srand(time(0)); vector <int> poc; for (int i=0; i<n; ++i) poc.pb(i); random_shuffle(poc.begin(), poc.end()); rek(poc); } /* 5 0 1 0 2 1 3 1 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...