# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
601476 | 2022-07-22T05:27:22 Z | 박상훈(#8471) | Stranded Far From Home (BOI22_island) | C++17 | 252 ms | 34540 KB |
#include <bits/stdc++.h> typedef long long ll; using namespace std; vector<int> adj[200200], G[200200]; int a[200200]; struct DSU{ int path[200200]; ll S[200200]; void init(int n){for (int i=1;i<=n;i++) path[i] = i, S[i] = a[i];} int find(int s){ if (s==path[s]) return s; return path[s] = find(path[s]); } void merge(int s, int v){ s = find(s), v = find(v); if (s==v) return; if (S[v] >= a[s]) G[s].push_back(v); path[v] = s; S[s] += S[v]; } }dsu; bool on[200200], visited[200200]; void dfs(int s){ visited[s] = 1; for (auto &v:G[s]) dfs(v); } bool cmp(int x, int y){return a[x] < a[y];} int main(){ int n, m; scanf("%d %d", &n, &m); vector<int> I; for (int i=1;i<=n;i++){ scanf("%d", a+i); I.push_back(i); } for (int i=1;i<=m;i++){ int x, y; scanf("%d %d", &x, &y); adj[x].push_back(y); adj[y].push_back(x); } sort(I.begin(), I.end(), cmp); dsu.init(n+1); for (auto &s:I){ on[s] = 1; for (auto &v:adj[s]) if (on[v]){ dsu.merge(s, v); } } dfs(I.back()); for (int i=1;i<=n;i++) printf("%d", visited[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Correct | 6 ms | 9724 KB | Output is correct |
3 | Correct | 5 ms | 9684 KB | Output is correct |
4 | Correct | 9 ms | 9812 KB | Output is correct |
5 | Correct | 7 ms | 9812 KB | Output is correct |
6 | Correct | 6 ms | 9812 KB | Output is correct |
7 | Correct | 6 ms | 9812 KB | Output is correct |
8 | Correct | 6 ms | 9812 KB | Output is correct |
9 | Correct | 6 ms | 9900 KB | Output is correct |
10 | Correct | 6 ms | 9828 KB | Output is correct |
11 | Correct | 7 ms | 9812 KB | Output is correct |
12 | Correct | 6 ms | 9788 KB | Output is correct |
13 | Correct | 8 ms | 9900 KB | Output is correct |
14 | Correct | 7 ms | 9752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Correct | 5 ms | 9684 KB | Output is correct |
3 | Correct | 175 ms | 25272 KB | Output is correct |
4 | Correct | 195 ms | 27400 KB | Output is correct |
5 | Correct | 169 ms | 24280 KB | Output is correct |
6 | Correct | 203 ms | 25108 KB | Output is correct |
7 | Correct | 199 ms | 25876 KB | Output is correct |
8 | Correct | 237 ms | 27524 KB | Output is correct |
9 | Correct | 176 ms | 24016 KB | Output is correct |
10 | Correct | 129 ms | 24124 KB | Output is correct |
11 | Correct | 138 ms | 25380 KB | Output is correct |
12 | Correct | 199 ms | 25988 KB | Output is correct |
13 | Correct | 183 ms | 27380 KB | Output is correct |
14 | Correct | 181 ms | 28488 KB | Output is correct |
15 | Correct | 186 ms | 33784 KB | Output is correct |
16 | Correct | 140 ms | 32624 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Correct | 196 ms | 22740 KB | Output is correct |
3 | Correct | 224 ms | 25460 KB | Output is correct |
4 | Correct | 182 ms | 30380 KB | Output is correct |
5 | Correct | 173 ms | 28812 KB | Output is correct |
6 | Correct | 225 ms | 26128 KB | Output is correct |
7 | Correct | 200 ms | 33460 KB | Output is correct |
8 | Correct | 198 ms | 33472 KB | Output is correct |
9 | Correct | 116 ms | 32444 KB | Output is correct |
10 | Correct | 182 ms | 25120 KB | Output is correct |
11 | Correct | 174 ms | 26300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Correct | 205 ms | 23440 KB | Output is correct |
3 | Correct | 230 ms | 27544 KB | Output is correct |
4 | Correct | 238 ms | 25096 KB | Output is correct |
5 | Correct | 207 ms | 28860 KB | Output is correct |
6 | Correct | 206 ms | 27896 KB | Output is correct |
7 | Correct | 132 ms | 26724 KB | Output is correct |
8 | Correct | 124 ms | 31284 KB | Output is correct |
9 | Correct | 133 ms | 20008 KB | Output is correct |
10 | Correct | 174 ms | 25704 KB | Output is correct |
11 | Correct | 182 ms | 25072 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Correct | 6 ms | 9724 KB | Output is correct |
3 | Correct | 5 ms | 9684 KB | Output is correct |
4 | Correct | 9 ms | 9812 KB | Output is correct |
5 | Correct | 7 ms | 9812 KB | Output is correct |
6 | Correct | 6 ms | 9812 KB | Output is correct |
7 | Correct | 6 ms | 9812 KB | Output is correct |
8 | Correct | 6 ms | 9812 KB | Output is correct |
9 | Correct | 6 ms | 9900 KB | Output is correct |
10 | Correct | 6 ms | 9828 KB | Output is correct |
11 | Correct | 7 ms | 9812 KB | Output is correct |
12 | Correct | 6 ms | 9788 KB | Output is correct |
13 | Correct | 8 ms | 9900 KB | Output is correct |
14 | Correct | 7 ms | 9752 KB | Output is correct |
15 | Correct | 5 ms | 9684 KB | Output is correct |
16 | Correct | 5 ms | 9684 KB | Output is correct |
17 | Correct | 175 ms | 25272 KB | Output is correct |
18 | Correct | 195 ms | 27400 KB | Output is correct |
19 | Correct | 169 ms | 24280 KB | Output is correct |
20 | Correct | 203 ms | 25108 KB | Output is correct |
21 | Correct | 199 ms | 25876 KB | Output is correct |
22 | Correct | 237 ms | 27524 KB | Output is correct |
23 | Correct | 176 ms | 24016 KB | Output is correct |
24 | Correct | 129 ms | 24124 KB | Output is correct |
25 | Correct | 138 ms | 25380 KB | Output is correct |
26 | Correct | 199 ms | 25988 KB | Output is correct |
27 | Correct | 183 ms | 27380 KB | Output is correct |
28 | Correct | 181 ms | 28488 KB | Output is correct |
29 | Correct | 186 ms | 33784 KB | Output is correct |
30 | Correct | 140 ms | 32624 KB | Output is correct |
31 | Correct | 5 ms | 9684 KB | Output is correct |
32 | Correct | 196 ms | 22740 KB | Output is correct |
33 | Correct | 224 ms | 25460 KB | Output is correct |
34 | Correct | 182 ms | 30380 KB | Output is correct |
35 | Correct | 173 ms | 28812 KB | Output is correct |
36 | Correct | 225 ms | 26128 KB | Output is correct |
37 | Correct | 200 ms | 33460 KB | Output is correct |
38 | Correct | 198 ms | 33472 KB | Output is correct |
39 | Correct | 116 ms | 32444 KB | Output is correct |
40 | Correct | 182 ms | 25120 KB | Output is correct |
41 | Correct | 174 ms | 26300 KB | Output is correct |
42 | Correct | 5 ms | 9684 KB | Output is correct |
43 | Correct | 205 ms | 23440 KB | Output is correct |
44 | Correct | 230 ms | 27544 KB | Output is correct |
45 | Correct | 238 ms | 25096 KB | Output is correct |
46 | Correct | 207 ms | 28860 KB | Output is correct |
47 | Correct | 206 ms | 27896 KB | Output is correct |
48 | Correct | 132 ms | 26724 KB | Output is correct |
49 | Correct | 124 ms | 31284 KB | Output is correct |
50 | Correct | 133 ms | 20008 KB | Output is correct |
51 | Correct | 174 ms | 25704 KB | Output is correct |
52 | Correct | 182 ms | 25072 KB | Output is correct |
53 | Correct | 6 ms | 9684 KB | Output is correct |
54 | Correct | 5 ms | 9684 KB | Output is correct |
55 | Correct | 5 ms | 9684 KB | Output is correct |
56 | Correct | 7 ms | 9812 KB | Output is correct |
57 | Correct | 6 ms | 9812 KB | Output is correct |
58 | Correct | 6 ms | 9852 KB | Output is correct |
59 | Correct | 6 ms | 9812 KB | Output is correct |
60 | Correct | 6 ms | 9848 KB | Output is correct |
61 | Correct | 7 ms | 9976 KB | Output is correct |
62 | Correct | 7 ms | 9812 KB | Output is correct |
63 | Correct | 7 ms | 9812 KB | Output is correct |
64 | Correct | 7 ms | 9812 KB | Output is correct |
65 | Correct | 9 ms | 9812 KB | Output is correct |
66 | Correct | 7 ms | 9804 KB | Output is correct |
67 | Correct | 168 ms | 28240 KB | Output is correct |
68 | Correct | 177 ms | 27724 KB | Output is correct |
69 | Correct | 200 ms | 23708 KB | Output is correct |
70 | Correct | 188 ms | 25276 KB | Output is correct |
71 | Correct | 187 ms | 24560 KB | Output is correct |
72 | Correct | 210 ms | 27268 KB | Output is correct |
73 | Correct | 182 ms | 24152 KB | Output is correct |
74 | Correct | 152 ms | 22260 KB | Output is correct |
75 | Correct | 132 ms | 24096 KB | Output is correct |
76 | Correct | 170 ms | 25420 KB | Output is correct |
77 | Correct | 205 ms | 27236 KB | Output is correct |
78 | Correct | 160 ms | 27248 KB | Output is correct |
79 | Correct | 179 ms | 32516 KB | Output is correct |
80 | Correct | 126 ms | 33504 KB | Output is correct |
81 | Correct | 196 ms | 25024 KB | Output is correct |
82 | Correct | 218 ms | 25964 KB | Output is correct |
83 | Correct | 202 ms | 26480 KB | Output is correct |
84 | Correct | 149 ms | 28436 KB | Output is correct |
85 | Correct | 204 ms | 27324 KB | Output is correct |
86 | Correct | 213 ms | 34540 KB | Output is correct |
87 | Correct | 187 ms | 34440 KB | Output is correct |
88 | Correct | 164 ms | 24300 KB | Output is correct |
89 | Correct | 227 ms | 23704 KB | Output is correct |
90 | Correct | 202 ms | 25892 KB | Output is correct |
91 | Correct | 215 ms | 27780 KB | Output is correct |
92 | Correct | 252 ms | 27892 KB | Output is correct |
93 | Correct | 221 ms | 28008 KB | Output is correct |
94 | Correct | 198 ms | 27452 KB | Output is correct |
95 | Correct | 155 ms | 26928 KB | Output is correct |
96 | Correct | 122 ms | 30888 KB | Output is correct |
97 | Correct | 134 ms | 20356 KB | Output is correct |
98 | Correct | 195 ms | 27124 KB | Output is correct |
99 | Correct | 179 ms | 26384 KB | Output is correct |
100 | Correct | 54 ms | 13900 KB | Output is correct |
101 | Correct | 234 ms | 27380 KB | Output is correct |
102 | Correct | 217 ms | 25380 KB | Output is correct |
103 | Correct | 194 ms | 22360 KB | Output is correct |
104 | Correct | 213 ms | 23864 KB | Output is correct |