답안 #573683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
573683 2022-06-07T05:02:10 Z pavement Stranded Far From Home (BOI22_island) C++17
100 / 100
556 ms 64608 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using db = double;
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using iii = tuple<int, int, int>;
using iiii = tuple<int, int, int, int>;
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

int N, M, link[200005], sz[200005], mrk[200005], S[200005], off[200005];
vector<int> adj[200005], nodes[200005];
map<int, vector<int> > vec;

int find(int x) {
	if (x == link[x]) return x;
	return link[x] = find(link[x]);
}

void unite(int a, int b) {
	a = find(a);
	b = find(b);
	if (a == b) return;
	if (sz[b] > sz[a]) swap(a, b);
	sz[a] += sz[b];
	S[a] += S[b];
	for (int i : nodes[b]) {
		mrk[i] += off[b] - off[a];
		nodes[a].pb(i);
	}
	link[b] = a;
}

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> S[i];
		link[i] = i;
		sz[i] = 1;
		nodes[i].pb(i);
		vec[S[i]].pb(i);
	}
	for (int i = 1, u, v; i <= M; i++) {
		cin >> u >> v;
		if (S[v] <= S[u]) adj[u].pb(v);
		if (S[u] <= S[v]) adj[v].pb(u);
	}
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		for (auto i : it->second)
			for (int j : adj[i]) {
				if (S[find(j)] < it->first) off[find(j)]++;
				unite(i, j);
			}
	}
	for (int i = 1; i <= N; i++)
		cout << (mrk[i] + off[find(i)] > 0 ? '0' : '1');
	cout << '\n';
}

Compilation message

island.cpp:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 6 ms 10068 KB Output is correct
5 Correct 7 ms 10096 KB Output is correct
6 Correct 6 ms 9940 KB Output is correct
7 Correct 6 ms 10068 KB Output is correct
8 Correct 7 ms 10076 KB Output is correct
9 Correct 6 ms 9940 KB Output is correct
10 Correct 7 ms 10196 KB Output is correct
11 Correct 7 ms 10196 KB Output is correct
12 Correct 7 ms 10196 KB Output is correct
13 Correct 6 ms 9940 KB Output is correct
14 Correct 6 ms 9940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 6 ms 9684 KB Output is correct
3 Correct 194 ms 53276 KB Output is correct
4 Correct 141 ms 33620 KB Output is correct
5 Correct 235 ms 58852 KB Output is correct
6 Correct 240 ms 55620 KB Output is correct
7 Correct 254 ms 60968 KB Output is correct
8 Correct 198 ms 34068 KB Output is correct
9 Correct 192 ms 63656 KB Output is correct
10 Correct 168 ms 45464 KB Output is correct
11 Correct 160 ms 34684 KB Output is correct
12 Correct 214 ms 37240 KB Output is correct
13 Correct 136 ms 32568 KB Output is correct
14 Correct 139 ms 32620 KB Output is correct
15 Correct 173 ms 52296 KB Output is correct
16 Correct 135 ms 51780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 448 ms 64456 KB Output is correct
3 Correct 438 ms 59688 KB Output is correct
4 Correct 148 ms 32576 KB Output is correct
5 Correct 143 ms 32740 KB Output is correct
6 Correct 447 ms 64568 KB Output is correct
7 Correct 174 ms 52248 KB Output is correct
8 Correct 202 ms 52296 KB Output is correct
9 Correct 151 ms 51844 KB Output is correct
10 Correct 173 ms 40512 KB Output is correct
11 Correct 169 ms 36020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 236 ms 36344 KB Output is correct
3 Correct 266 ms 37576 KB Output is correct
4 Correct 259 ms 39640 KB Output is correct
5 Correct 260 ms 40260 KB Output is correct
6 Correct 229 ms 36352 KB Output is correct
7 Correct 165 ms 34720 KB Output is correct
8 Correct 88 ms 31936 KB Output is correct
9 Correct 163 ms 24448 KB Output is correct
10 Correct 258 ms 42976 KB Output is correct
11 Correct 155 ms 34748 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 6 ms 9684 KB Output is correct
4 Correct 6 ms 10068 KB Output is correct
5 Correct 7 ms 10096 KB Output is correct
6 Correct 6 ms 9940 KB Output is correct
7 Correct 6 ms 10068 KB Output is correct
8 Correct 7 ms 10076 KB Output is correct
9 Correct 6 ms 9940 KB Output is correct
10 Correct 7 ms 10196 KB Output is correct
11 Correct 7 ms 10196 KB Output is correct
12 Correct 7 ms 10196 KB Output is correct
13 Correct 6 ms 9940 KB Output is correct
14 Correct 6 ms 9940 KB Output is correct
15 Correct 5 ms 9684 KB Output is correct
16 Correct 6 ms 9684 KB Output is correct
17 Correct 194 ms 53276 KB Output is correct
18 Correct 141 ms 33620 KB Output is correct
19 Correct 235 ms 58852 KB Output is correct
20 Correct 240 ms 55620 KB Output is correct
21 Correct 254 ms 60968 KB Output is correct
22 Correct 198 ms 34068 KB Output is correct
23 Correct 192 ms 63656 KB Output is correct
24 Correct 168 ms 45464 KB Output is correct
25 Correct 160 ms 34684 KB Output is correct
26 Correct 214 ms 37240 KB Output is correct
27 Correct 136 ms 32568 KB Output is correct
28 Correct 139 ms 32620 KB Output is correct
29 Correct 173 ms 52296 KB Output is correct
30 Correct 135 ms 51780 KB Output is correct
31 Correct 5 ms 9684 KB Output is correct
32 Correct 448 ms 64456 KB Output is correct
33 Correct 438 ms 59688 KB Output is correct
34 Correct 148 ms 32576 KB Output is correct
35 Correct 143 ms 32740 KB Output is correct
36 Correct 447 ms 64568 KB Output is correct
37 Correct 174 ms 52248 KB Output is correct
38 Correct 202 ms 52296 KB Output is correct
39 Correct 151 ms 51844 KB Output is correct
40 Correct 173 ms 40512 KB Output is correct
41 Correct 169 ms 36020 KB Output is correct
42 Correct 6 ms 9684 KB Output is correct
43 Correct 236 ms 36344 KB Output is correct
44 Correct 266 ms 37576 KB Output is correct
45 Correct 259 ms 39640 KB Output is correct
46 Correct 260 ms 40260 KB Output is correct
47 Correct 229 ms 36352 KB Output is correct
48 Correct 165 ms 34720 KB Output is correct
49 Correct 88 ms 31936 KB Output is correct
50 Correct 163 ms 24448 KB Output is correct
51 Correct 258 ms 42976 KB Output is correct
52 Correct 155 ms 34748 KB Output is correct
53 Correct 5 ms 9684 KB Output is correct
54 Correct 5 ms 9740 KB Output is correct
55 Correct 5 ms 9684 KB Output is correct
56 Correct 8 ms 10152 KB Output is correct
57 Correct 7 ms 10068 KB Output is correct
58 Correct 9 ms 9940 KB Output is correct
59 Correct 8 ms 10068 KB Output is correct
60 Correct 7 ms 10112 KB Output is correct
61 Correct 7 ms 9988 KB Output is correct
62 Correct 7 ms 10196 KB Output is correct
63 Correct 12 ms 10196 KB Output is correct
64 Correct 7 ms 10196 KB Output is correct
65 Correct 7 ms 9940 KB Output is correct
66 Correct 7 ms 9940 KB Output is correct
67 Correct 220 ms 53268 KB Output is correct
68 Correct 176 ms 33584 KB Output is correct
69 Correct 263 ms 58780 KB Output is correct
70 Correct 305 ms 55524 KB Output is correct
71 Correct 319 ms 60872 KB Output is correct
72 Correct 219 ms 34132 KB Output is correct
73 Correct 208 ms 63572 KB Output is correct
74 Correct 212 ms 45476 KB Output is correct
75 Correct 188 ms 34688 KB Output is correct
76 Correct 287 ms 37192 KB Output is correct
77 Correct 180 ms 32612 KB Output is correct
78 Correct 202 ms 32600 KB Output is correct
79 Correct 195 ms 52208 KB Output is correct
80 Correct 149 ms 51816 KB Output is correct
81 Correct 556 ms 64448 KB Output is correct
82 Correct 454 ms 59760 KB Output is correct
83 Correct 172 ms 32568 KB Output is correct
84 Correct 168 ms 32916 KB Output is correct
85 Correct 443 ms 64608 KB Output is correct
86 Correct 185 ms 52216 KB Output is correct
87 Correct 212 ms 52280 KB Output is correct
88 Correct 191 ms 40576 KB Output is correct
89 Correct 189 ms 36076 KB Output is correct
90 Correct 277 ms 36312 KB Output is correct
91 Correct 262 ms 37560 KB Output is correct
92 Correct 238 ms 39400 KB Output is correct
93 Correct 274 ms 40204 KB Output is correct
94 Correct 251 ms 36404 KB Output is correct
95 Correct 170 ms 34680 KB Output is correct
96 Correct 95 ms 32016 KB Output is correct
97 Correct 138 ms 24328 KB Output is correct
98 Correct 315 ms 43000 KB Output is correct
99 Correct 154 ms 34856 KB Output is correct
100 Correct 45 ms 13164 KB Output is correct
101 Correct 444 ms 54020 KB Output is correct
102 Correct 197 ms 31960 KB Output is correct
103 Correct 352 ms 43380 KB Output is correct
104 Correct 470 ms 54908 KB Output is correct