제출 #375319

#제출 시각아이디문제언어결과실행 시간메모리
375319casperwangMeetings (JOI19_meetings)C++14
100 / 100
1893 ms1344 KiB
#include "meetings.h" #define All(x) x.begin(), x.end() #define pb push_back #include <bits/stdc++.h> using namespace std; #define debug(args...) kout("[ " + string(#args) + " ]", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); } template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; } void solve_set(vector <int> V) { srand(time(NULL)); random_shuffle(All(V)); set <int> R; vector <int> V2; for (int i : V) R.insert(i); int m = Query(V[0], V[1], V[2]); if (V.size() == 3) { for (int i = 0; i < 3; i++) { if (m != V[i]) { debug(min(m, V[i]), max(m, V[i])); Bridge(min(m, V[i]), max(m, V[i])); } } return; } for (int i = 0; i < 3; i++) { if (m == V[i]) continue; vector <int> A, B; R.erase(V[i]); for (int j : V) { if (j == V[i] || j == m) continue; int d = Query(m, V[i], j); if (d == V[i]) B.pb(j), R.erase(j); else if (d != m) A.pb(j), R.erase(j); } if (A.size() == 0) { debug(min(m, V[i]), max(m, V[i])); Bridge(min(m, V[i]), max(m, V[i])); } else if (A.size() == 1) { debug(min(A[0], m), max(A[0], m)); Bridge(min(A[0], m), max(A[0], m)); debug(min(A[0], V[i]), max(A[0], V[i])); Bridge(min(A[0], V[i]), max(A[0], V[i])); } else if (A.size() >= 2) { A.pb(m); A.pb(V[i]); solve_set(A); } if (B.size() == 1) { debug(min(B[0], V[i]), max(B[0], V[i])); Bridge(min(B[0], V[i]), max(B[0], V[i])); } else if (B.size() >= 2) { B.pb(V[i]); solve_set(B); } } for (int i : R) V2.pb(i); if (V2.size() == 2) { debug(min(V2[0], V2[1]), max(V2[0], V2[1])); Bridge(min(V2[0], V2[1]), max(V2[0], V2[1])); } else if (V2.size() >= 3) { solve_set(V2); } } void Solve(int N) { vector <int> arr; for (int i = 0; i < N; i++) arr.pb(i); solve_set(arr); return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...