# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681884 | nutella | Virus Experiment (JOI19_virus) | C++17 | 2097 ms | 45900 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
constexpr int dx[]{-1, 0, 1, 0}, dy[]{0, 1, 0, -1};
struct DSU {
vector<int> p, sz;
vector<vector<int>> subtree;
DSU() = default;
DSU(int n) : p(n), sz(n, 1), subtree(n) {
iota(p.begin(), p.end(), 0);
for (int i = 0; i < n; ++i) {
subtree[i] = {i};
}
}
int leader(int x) {
return x == p[x] ? x : p[x] = leader(p[x]);
}
bool unite(int a, int b) {
a = leader(a), b = leader(b);
if (a == b) {
return false;
}
if (sz[a] < sz[b]) {
swap(a, b);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |