# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
937429 | 2024-03-04T03:47:32 Z | weakweakweak | Stranded Far From Home (BOI22_island) | C++14 | 175 ms | 43680 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long int n, m, s[201000], fa[201000], sz[201000], vis[201000] = {0}, ans[201000], dead[201000] = {0}; ll w[201000]; vector <int> e[201000], ne[201000]; int find (int x) {return fa[x] == x? x : fa[x] = find(fa[x]);} void dfs(int i) { ans[i] = !dead[i]; for (int j : ne[i]) { dead[j] |= dead[i]; dfs(j); } return;} int main () { //輸入、建圖 ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> s[i]; fa[i] = i, w[i] = s[i], sz[i] = 1; } for (int i = 0, x, y; i < m; i++) { cin >> x >> y; e[x].push_back(y);e[y].push_back(x); } //做事 vector<int> p; for (int i = 1; i <= n; i++) p.push_back(i); sort(p.begin(), p.end(), [&s](int & a, int & b){return s[a] < s[b];}); for (int ii = 0; ii < n; ii++) { int i = p[ii]; for (int j : e[i]) { if (!vis[j] or i == find(j)) continue; if (w[find(j)] < s[i]) dead[find(j)] = 1; ne[i].push_back(find(j)); w[i] += w[find(j)]; fa[find(j)] = i; } vis[i] = 1; } //從根往下跑 int rt = find(1); dfs(rt); //輸出 for (int i = 1; i <= n; i++) cout << ans[i]; cout << '\n'; return 0;}
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 14936 KB | Output is correct |
2 | Correct | 4 ms | 14940 KB | Output is correct |
3 | Correct | 2 ms | 12892 KB | Output is correct |
4 | Correct | 4 ms | 15008 KB | Output is correct |
5 | Correct | 4 ms | 14940 KB | Output is correct |
6 | Correct | 4 ms | 15160 KB | Output is correct |
7 | Correct | 4 ms | 14940 KB | Output is correct |
8 | Correct | 4 ms | 15004 KB | Output is correct |
9 | Correct | 4 ms | 15196 KB | Output is correct |
10 | Correct | 4 ms | 14968 KB | Output is correct |
11 | Correct | 4 ms | 14940 KB | Output is correct |
12 | Correct | 4 ms | 15004 KB | Output is correct |
13 | Correct | 4 ms | 14940 KB | Output is correct |
14 | Correct | 3 ms | 14940 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 14996 KB | Output is correct |
2 | Correct | 2 ms | 12892 KB | Output is correct |
3 | Correct | 95 ms | 35860 KB | Output is correct |
4 | Correct | 104 ms | 31944 KB | Output is correct |
5 | Correct | 129 ms | 31176 KB | Output is correct |
6 | Correct | 123 ms | 31748 KB | Output is correct |
7 | Correct | 108 ms | 31660 KB | Output is correct |
8 | Correct | 111 ms | 32972 KB | Output is correct |
9 | Correct | 89 ms | 30676 KB | Output is correct |
10 | Correct | 86 ms | 28996 KB | Output is correct |
11 | Correct | 71 ms | 28736 KB | Output is correct |
12 | Correct | 112 ms | 30416 KB | Output is correct |
13 | Correct | 86 ms | 32152 KB | Output is correct |
14 | Correct | 117 ms | 32248 KB | Output is correct |
15 | Correct | 105 ms | 43680 KB | Output is correct |
16 | Correct | 77 ms | 42444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 12892 KB | Output is correct |
2 | Correct | 131 ms | 31712 KB | Output is correct |
3 | Correct | 175 ms | 32312 KB | Output is correct |
4 | Correct | 96 ms | 33728 KB | Output is correct |
5 | Correct | 88 ms | 32188 KB | Output is correct |
6 | Correct | 143 ms | 31828 KB | Output is correct |
7 | Correct | 156 ms | 43536 KB | Output is correct |
8 | Correct | 115 ms | 43464 KB | Output is correct |
9 | Correct | 77 ms | 42444 KB | Output is correct |
10 | Correct | 94 ms | 30168 KB | Output is correct |
11 | Correct | 111 ms | 30392 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 12892 KB | Output is correct |
2 | Correct | 143 ms | 32264 KB | Output is correct |
3 | Correct | 131 ms | 31936 KB | Output is correct |
4 | Correct | 132 ms | 31952 KB | Output is correct |
5 | Correct | 116 ms | 31948 KB | Output is correct |
6 | Correct | 109 ms | 32448 KB | Output is correct |
7 | Correct | 79 ms | 31600 KB | Output is correct |
8 | Correct | 86 ms | 37512 KB | Output is correct |
9 | Correct | 81 ms | 25356 KB | Output is correct |
10 | Correct | 126 ms | 30224 KB | Output is correct |
11 | Correct | 105 ms | 30484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 14936 KB | Output is correct |
2 | Correct | 4 ms | 14940 KB | Output is correct |
3 | Correct | 2 ms | 12892 KB | Output is correct |
4 | Correct | 4 ms | 15008 KB | Output is correct |
5 | Correct | 4 ms | 14940 KB | Output is correct |
6 | Correct | 4 ms | 15160 KB | Output is correct |
7 | Correct | 4 ms | 14940 KB | Output is correct |
8 | Correct | 4 ms | 15004 KB | Output is correct |
9 | Correct | 4 ms | 15196 KB | Output is correct |
10 | Correct | 4 ms | 14968 KB | Output is correct |
11 | Correct | 4 ms | 14940 KB | Output is correct |
12 | Correct | 4 ms | 15004 KB | Output is correct |
13 | Correct | 4 ms | 14940 KB | Output is correct |
14 | Correct | 3 ms | 14940 KB | Output is correct |
15 | Correct | 4 ms | 14996 KB | Output is correct |
16 | Correct | 2 ms | 12892 KB | Output is correct |
17 | Correct | 95 ms | 35860 KB | Output is correct |
18 | Correct | 104 ms | 31944 KB | Output is correct |
19 | Correct | 129 ms | 31176 KB | Output is correct |
20 | Correct | 123 ms | 31748 KB | Output is correct |
21 | Correct | 108 ms | 31660 KB | Output is correct |
22 | Correct | 111 ms | 32972 KB | Output is correct |
23 | Correct | 89 ms | 30676 KB | Output is correct |
24 | Correct | 86 ms | 28996 KB | Output is correct |
25 | Correct | 71 ms | 28736 KB | Output is correct |
26 | Correct | 112 ms | 30416 KB | Output is correct |
27 | Correct | 86 ms | 32152 KB | Output is correct |
28 | Correct | 117 ms | 32248 KB | Output is correct |
29 | Correct | 105 ms | 43680 KB | Output is correct |
30 | Correct | 77 ms | 42444 KB | Output is correct |
31 | Correct | 2 ms | 12892 KB | Output is correct |
32 | Correct | 131 ms | 31712 KB | Output is correct |
33 | Correct | 175 ms | 32312 KB | Output is correct |
34 | Correct | 96 ms | 33728 KB | Output is correct |
35 | Correct | 88 ms | 32188 KB | Output is correct |
36 | Correct | 143 ms | 31828 KB | Output is correct |
37 | Correct | 156 ms | 43536 KB | Output is correct |
38 | Correct | 115 ms | 43464 KB | Output is correct |
39 | Correct | 77 ms | 42444 KB | Output is correct |
40 | Correct | 94 ms | 30168 KB | Output is correct |
41 | Correct | 111 ms | 30392 KB | Output is correct |
42 | Correct | 2 ms | 12892 KB | Output is correct |
43 | Correct | 143 ms | 32264 KB | Output is correct |
44 | Correct | 131 ms | 31936 KB | Output is correct |
45 | Correct | 132 ms | 31952 KB | Output is correct |
46 | Correct | 116 ms | 31948 KB | Output is correct |
47 | Correct | 109 ms | 32448 KB | Output is correct |
48 | Correct | 79 ms | 31600 KB | Output is correct |
49 | Correct | 86 ms | 37512 KB | Output is correct |
50 | Correct | 81 ms | 25356 KB | Output is correct |
51 | Correct | 126 ms | 30224 KB | Output is correct |
52 | Correct | 105 ms | 30484 KB | Output is correct |
53 | Correct | 3 ms | 14936 KB | Output is correct |
54 | Correct | 3 ms | 14940 KB | Output is correct |
55 | Correct | 4 ms | 12892 KB | Output is correct |
56 | Correct | 4 ms | 15044 KB | Output is correct |
57 | Correct | 4 ms | 14940 KB | Output is correct |
58 | Correct | 3 ms | 14940 KB | Output is correct |
59 | Correct | 4 ms | 14940 KB | Output is correct |
60 | Correct | 4 ms | 14936 KB | Output is correct |
61 | Correct | 3 ms | 15196 KB | Output is correct |
62 | Correct | 4 ms | 14940 KB | Output is correct |
63 | Correct | 5 ms | 14936 KB | Output is correct |
64 | Correct | 4 ms | 14936 KB | Output is correct |
65 | Correct | 4 ms | 14940 KB | Output is correct |
66 | Correct | 3 ms | 14936 KB | Output is correct |
67 | Correct | 94 ms | 35892 KB | Output is correct |
68 | Correct | 94 ms | 31944 KB | Output is correct |
69 | Correct | 105 ms | 31144 KB | Output is correct |
70 | Correct | 113 ms | 31684 KB | Output is correct |
71 | Correct | 113 ms | 31796 KB | Output is correct |
72 | Correct | 110 ms | 32944 KB | Output is correct |
73 | Correct | 96 ms | 30664 KB | Output is correct |
74 | Correct | 78 ms | 28960 KB | Output is correct |
75 | Correct | 70 ms | 28744 KB | Output is correct |
76 | Correct | 117 ms | 30416 KB | Output is correct |
77 | Correct | 103 ms | 32200 KB | Output is correct |
78 | Correct | 87 ms | 32200 KB | Output is correct |
79 | Correct | 108 ms | 43464 KB | Output is correct |
80 | Correct | 83 ms | 42700 KB | Output is correct |
81 | Correct | 137 ms | 31944 KB | Output is correct |
82 | Correct | 134 ms | 31860 KB | Output is correct |
83 | Correct | 106 ms | 33640 KB | Output is correct |
84 | Correct | 90 ms | 32720 KB | Output is correct |
85 | Correct | 130 ms | 31940 KB | Output is correct |
86 | Correct | 119 ms | 43556 KB | Output is correct |
87 | Correct | 122 ms | 43460 KB | Output is correct |
88 | Correct | 123 ms | 30348 KB | Output is correct |
89 | Correct | 118 ms | 30556 KB | Output is correct |
90 | Correct | 132 ms | 32400 KB | Output is correct |
91 | Correct | 135 ms | 31940 KB | Output is correct |
92 | Correct | 133 ms | 31948 KB | Output is correct |
93 | Correct | 112 ms | 31948 KB | Output is correct |
94 | Correct | 120 ms | 32452 KB | Output is correct |
95 | Correct | 79 ms | 31692 KB | Output is correct |
96 | Correct | 83 ms | 37368 KB | Output is correct |
97 | Correct | 72 ms | 25288 KB | Output is correct |
98 | Correct | 107 ms | 30412 KB | Output is correct |
99 | Correct | 102 ms | 30416 KB | Output is correct |
100 | Correct | 33 ms | 19284 KB | Output is correct |
101 | Correct | 155 ms | 31948 KB | Output is correct |
102 | Correct | 97 ms | 31688 KB | Output is correct |
103 | Correct | 134 ms | 32424 KB | Output is correct |
104 | Correct | 157 ms | 32480 KB | Output is correct |