제출 #482030

#제출 시각아이디문제언어결과실행 시간메모리
482030Lam_lai_cuoc_doiMeetings (JOI19_meetings)C++17
100 / 100
971 ms16668 KiB
#include <bits/stdc++.h> #include "meetings.h" using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template <class T> void read(T &x) { x = 0; register int c; while ((c = getchar()) && (c > '9' || c < '0')) ; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; } constexpr bool typetest = 0; constexpr int N = 2e3 + 5; //Ảo thật đấy int lcam[N][N]; int LCA(int u, int v) { if (u == v) return u; if (u == 0 || v == 0) return 0; if (lcam[u][v] != -1) return lcam[u][v]; return (lcam[u][v] = lcam[v][u] = Query(0, u, v)); } void Recursive(int root, vector<int> &s) { if (s.size() == 1) return; if (s.size() == 2) { Bridge(min(s[0], s[1]), max(s[0], s[1])); return; } map<int, vector<int>> subtree; int u; do { u = s[rand() % s.size()]; } while (u == root); vector<int> chain; for (auto i : s) { int lca = LCA(i, u); if (lca == i) chain.emplace_back(i); subtree[lca].emplace_back(i); } sort(chain.begin(), chain.end(), [&](const int &x, const int &y) { return LCA(x, y) == x; }); for (int i = 0; i < (int)chain.size() - 1; ++i) Bridge(min(chain[i], chain[i + 1]), max(chain[i], chain[i + 1])); for (auto i : subtree) Recursive(i.first, i.second); } void Solve(int n) { memset(lcam, -1, sizeof lcam); vector<int> s; for (int i = 0; i < n; ++i) s.emplace_back(i); random_shuffle(s.begin(), s.end()); Recursive(0, s); } /* void Read() { } void Solve() { } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("xor.INP", "r")) { freopen("xor.inp", "r", stdin); freopen("xor.out", "w", stdout); } int t(1); if (typetest) cin >> t; for (int _ = 1; _ <= t; ++_) { // cout << "Case #" << _ << ": "; Read(); Solve(); } // cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } */

컴파일 시 표준 에러 (stderr) 메시지

meetings.cpp: In function 'void read(T&)':
meetings.cpp:13:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   13 |     register int c;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...