제출 #374974

#제출 시각아이디문제언어결과실행 시간메모리
374974BartolMMeetings (JOI19_meetings)C++17
29 / 100
385 ms748 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; #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; 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); for (int x:v) { if (x==l || x==r) 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); l=y; if (y!=x) v_l.pb(y); } else { v_r.pb(x); r=y; if (y!=x) v_r.pb(y); } } } 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...