Submission #710855

#TimeUsernameProblemLanguageResultExecution timeMemory
710855PixelCatMeetings (JOI19_meetings)C++14
100 / 100
949 ms1052 KiB
#include "meetings.h" #include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define eb emplace_back #define int LL using namespace std; using LL = long long; using pii = pair<int, int>; const int MAXN = 2010; mt19937_64 rng(48763); vector<pii> edges; int m_qry(int a, int b, int c) { if(a == b) return a; if(a == c) return a; if(b == c) return b; return Query(a, b, c); } void solve(vector<int> &ids) { // for(auto &i:ids) cout << i << " "; // cout << endl; if(sz(ids) == 1) return; if(sz(ids) == 2) { edges.eb(ids[0], ids[1]); return; } int p1 = rng() % sz(ids); int p2 = rng() % sz(ids); while(p1 == p2) p2 = rng() % sz(ids); p1 = ids[p1]; p2 = ids[p2]; map<int, vector<int>> mp; vector<int> rts; for(auto &i:ids) { int r = m_qry(p1, p2, i); rts.eb(r); mp[r].eb(i); } for(auto &it:mp) solve(it.S); sort(all(rts)); rts.erase(unique(all(rts)), rts.end()); sort(all(rts), [&](int a, int b) { return m_qry(p1, a, b) == a; }); For(i, 0, sz(rts) - 2) edges.eb(rts[i], rts[i + 1]); } void Solve(int32_t n) { edges.clear(); vector<int> ids(n); For(i, 0, n - 1) ids[i] = i; solve(ids); for(auto &p:edges) { if(p.F > p.S) swap(p.F, p.S); Bridge(p.F, p.S); } } // int x = Query(0, 1, 2); // for (int u = 0; u < N - 1; ++u) { // Bridge(u, u + 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...