# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
879927 | 2023-11-28T10:28:26 Z | sleepntsheep | Stranded Far From Home (BOI22_island) | C++17 | 77 ms | 5996 KB |
#include <iostream> #include <utility> #include <vector> #include <tuple> #include <algorithm> int n, m, s[200000], p[200000], q[200000], r[200000]; int f(int x) { if (p[x] == x) return x; int w = f(p[x]); r[x] |= r[p[x]]; return p[x] = w; } void u_(int x, int y) { if ((x = f(x)) == (y = f(y))) return; if (q[x] < s[y]) r[x] = 1; q[y] += q[x]; p[x] = y; } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) scanf("%d", s+i), p[i] = i, q[i] = s[i]; std::vector<std::tuple<int, int, int>> e(m); for (auto &[w, u, v] : e) { scanf("%d%d", &u, &v); if (s[--u] > s[--v]) std::swap(u, v); w = s[v]; } std::sort(e.begin(), e.end()); for (auto [_, u, v] : e) u_(u, v); for (int i = 0; i < n; ++i) f(i), putchar(48+!r[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Incorrect | 1 ms | 2648 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Incorrect | 63 ms | 5980 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2392 KB | Output is correct |
2 | Incorrect | 70 ms | 5968 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Incorrect | 77 ms | 5996 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Incorrect | 1 ms | 2648 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |