제출 #374976

#제출 시각아이디문제언어결과실행 시간메모리
374976BartolMMeetings (JOI19_meetings)C++17
100 / 100
724 ms1024 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; const int N=2005; int n, uk; int bio[N]; #define DEBUG 0 void upit(int x, int y) { #if DEBUG printf("%d <-> %d\n", x, y); #endif Bridge(min(x, y), max(x, y)); } void rek(vector <int> v) { if (v.size()==1) return; for (int x:v) bio[x]=0; random_shuffle(v.begin(), v.end()); int l=v[0], r=v[1]; vector <int> v_l, v_r; v_l.pb(l); v_r.pb(r); bio[l]=bio[r]=1; for (int x:v) { if (x==l || x==r || bio[x]) continue; int y=Query(x, l, r); if (y==l) v_l.pb(x); else if (y==r) v_r.pb(x); else { if (v_l.size()<v_r.size()) { v_l.pb(x), bio[x]=1; l=y; if (y!=x) v_l.pb(y), bio[y]=1; } else { v_r.pb(x), bio[x]=1; r=y; if (y!=x) v_r.pb(y), bio[y]=1;; } } } upit(l, r); rek(v_l); rek(v_r); } void Solve(int nn) { n=nn; srand(time(0)); vector <int> poc; for (int i=0; i<n; ++i) poc.pb(i); 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...