# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1098843 | 2024-10-10T08:24:01 Z | not_amir | Stranded Far From Home (BOI22_island) | C++14 | 87 ms | 19216 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<pii> village(n); vector<vector<int>> G(n + 1); vector<int> parent(n + 1), vsize(n + 1); for(int i = 1; i <= n; i++) { int a; cin >> a; village[i - 1] = {a, i}; parent[i] = i; } sort(village.begin(), village.end()); for(int i = 1; i <= m; i++) { int a, b; cin >> a >> b; G[a].push_back(b); G[b].push_back(a); } vector<bool> visited(n + 1); for(auto [vs, v] : village) { vsize[v] = vs; visited[v] = true; for(int u : G[v]) { if(!visited[u]) continue; while(u != parent[u]) u = parent[u] = parent[parent[u]]; if(u == v) continue; vsize[v] += vsize[u]; if(vsize[u] >= vs) parent[u] = v; } } int v = village.back().second; while(v != parent[v]) v = parent[v] = parent[parent[v]]; for(int i = 1; i <= n; i++) { int u = i; while(u != parent[u]) u = parent[u] = parent[parent[u]]; if(u == v) cout << '1'; else cout << '0'; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 1 ms | 464 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Incorrect | 70 ms | 19216 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 78 ms | 18864 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 87 ms | 19156 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Incorrect | 1 ms | 464 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |