제출 #1134034

#제출 시각아이디문제언어결과실행 시간메모리
1134034alterio분수 공원 (IOI21_parks)C++20
5 / 100
73 ms17520 KiB
#include <bits/stdc++.h> #include "parks.h" using namespace std; #define all(x) (x).begin(), (x).end() const int mxn = 2e5 + 100; int ldr[mxn], rnk[mxn]; int Find(int x) { if (ldr[x] == x) return x; return ldr[x] = Find(ldr[x]); } void Union(int x, int y) { x = Find(x), y = Find(y); if (x == y) return; if (rnk[y] > rnk[x]) swap(x, y); rnk[x] += rnk[y]; ldr[y] = x; } int construct_roads(vector<int> x, vector<int> y) { int n = x.size(); if (x.size() == 1) { build({}, {}, {}, {}); return 1; } for (int i = 0; i < mxn; i++) ldr[i] = i, rnk[i] = 1; vector<pair<int, int>> V; for (int i = 0; i < n; i++) V.push_back({y[i], i}); sort(all(V)); for (int i = 0; i < n - 1; i++) { if (V[i + 1].first - V[i].first > 2) return 0; Union(V[i].second, V[i + 1].second); } set<int> s; for (int i = 0; i < n; i++) s.insert(Find(i)); if (s.size() != 1) return 0; vector<int> u, v, a, b; for (int i = 0; i < n - 1; i++) { u.push_back(V[i].second); v.push_back(V[i + 1].second); a.push_back(1); b.push_back(V[i].first + 1); } build(u, v, a, b); return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...