# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941326 | 2024-03-08T13:45:11 Z | prairie2022 | Stranded Far From Home (BOI22_island) | C++17 | 1 ms | 600 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second vector<int> dsu[2]; // biggest in group, discard?, sum of popularity inline int boss(int u, bool b){ int &bs = dsu[b][u]; if(bs==u) return u; return bs = boss(bs, b); } int main(){ cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; fill(dsu, dsu+3, vector<int>(n+1)); dsu[1][0] = 0; vector<pair<ll, int>> s(n+1); for(int i=1; i<=n; i++){ cin >> s[i].F; s[i].S = i; } vector<vector<int>> e(n+1); while(m--){ int a, b; cin >> a >> b; if(s[a]<s[b]) swap(a, b); e[a].push_back(b); } s[0] = {INT32_MAX, 0}; sort(s.begin(), s.end()); s.pop_back(); vector<ll> tot(n+1); for(const auto &[num, i] : s){ dsu[0][i] = dsu[1][i] = i; tot[i] = num; for(int v: e[i]){ v = boss(v, 0); if(v==i) continue; dsu[0][v] = i; dsu[1][v] = (tot[v]>=num)?i:0; tot[i] += tot[v]; } } for(int i=1; i<=n; i++) cout << "10"[!boss(i, 1)]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 600 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 600 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |