# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
593267 | 2022-07-10T17:34:02 Z | 1zaid1 | Stranded Far From Home (BOI22_island) | C++17 | 216 ms | 55068 KB |
#include <bits/stdc++.h> using namespace std; #define endl '\n' const int M = 4e5+1; #define int long long vector<int> node[M]; int p[M], sum[M], k[M]; vector<int> bt[M]; int find(int s) { return (s == p[s]?s:p[s]=find(p[s])); } void uni(int x, int y) { if (bt[x].size() < bt[y].size()) swap(x, y); for (int i:bt[y]) bt[x].push_back(i); bt[y].clear(); p[y] = x; sum[x] += sum[y]; } signed main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) cin >> k[i]; for (int i = 1; i <= m; i++) { int a, b; cin >> a >> b; if (p[a] >= b) node[a].push_back(b); else node[b].push_back(a); } vector<int> v; for (int i = 1; i <= n; i++) { p[i] = i; bt[i] = {i}; sum[i] = k[i]; } for (int i = 1; i <= n; i++) v.push_back(i); sort(v.begin(), v.end(), [](int a, int b) {return k[a] < k[b];}); for (int s:v) { for (int i:node[s]) { if (find(i) == find(s)) continue; if (sum[find(i)] < k[s]) bt[find(i)].clear(); uni(find(s), find(i)); } } bitset<200005> x; for (int i:bt[find(1)]) x[i] = 1; for (int i = 1; i <= n; i++) cout << x[i]; cout << endl; return 0; } /* 4 3 4 2 2 1 1 2 3 2 4 1 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 19028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 19084 KB | Output is correct |
2 | Correct | 10 ms | 19028 KB | Output is correct |
3 | Incorrect | 136 ms | 41788 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 19156 KB | Output is correct |
2 | Incorrect | 216 ms | 55068 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 19028 KB | Output is correct |
2 | Incorrect | 208 ms | 45492 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 19028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |