Submission #565833

# Submission time Handle Problem Language Result Execution time Memory
565833 2022-05-21T11:52:34 Z PiejanVDC Fountain Parks (IOI21_parks) C++17
15 / 100
677 ms 36368 KB
#include <bits/stdc++.h>
#include "parks.h"
using namespace std;

void build(vector<int>u, vector<int>v, vector<int>a, vector<int>b);

int construct_roads(std::vector<int> x, std::vector<int> y) {
	const int n = (int)x.size();
	set<pair<int,int>>s;
	set<pair<int,int>>t;
	map<pair<int,int>,int>id;
	for(int i = 0 ; i < n ; i++)
		s.insert({x[i], y[i]}), id[{x[i], y[i]}] = i;
	stack<pair<pair<int,int>, int>>st;
	st.push({{x[0], y[0]}, 0});
	s.erase(s.find({x[0], y[0]}));
	vector<int>u,v,a,b;
	auto process = [&] (int X, int Y, int T) -> void {
		s.erase(s.find({X,Y}));
		u.push_back(id[{X,Y}]);
		st.push({{X, Y}, T&1});
		if(T == 0) {
			v.push_back(id[{X-2,Y}]);
			if(t.count({X-1, Y+1}))
				t.insert({X-1, Y-1}), a.push_back(X-1), b.push_back(Y-1);
			else
				t.insert({X-1, Y+1}), a.push_back(X-1), b.push_back(Y+1);
		} else if(T == 1) {
			v.push_back(id[{X,Y+2}]);
			if(t.count({X+1, Y+1}))
				t.insert({X-1, Y+1}), a.push_back(X-1), b.push_back(Y+1);
			else
				t.insert({X+1, Y+1}), a.push_back(X+1), b.push_back(Y+1);
		} else if(T == 2) {
			v.push_back(id[{X+2,Y}]);
			if(t.count({X+1, Y-1}))
				t.insert({X+1, Y+1}), a.push_back(X+1), b.push_back(Y+1);
			else
				t.insert({X+1, Y-1}), a.push_back(X+1), b.push_back(Y-1);
		} else {
			v.push_back(id[{X,Y-2}]);
			if(t.count({X-1, Y-1}))
				t.insert({X+1, Y-1}), a.push_back(X+1), b.push_back(Y-1);
			else
				t.insert({X-1, Y-1}), a.push_back(X-1), b.push_back(Y-1);
		}
	};
	int cnt = 0;
	while(!st.empty()) {
		auto [x,y] = st.top().first;
		int d = st.top().second;
		st.pop();
		cnt++;
		if(d == 0) {
			if(s.count({x, y+2})) {
				process(x, y+2, 3);
				if(s.count({x+2,y}))
					process(x+2, y, 0);
				if(s.count({x-2,y}))
					process(x-2, y, 2);
				if(s.count({x, y-2}))
					process(x, y-2, 1);
			} else {
				if(s.count({x,y-2}))
					process(x, y-2, 1);
				if(s.count({x+2, y}))
					process(x+2, y, 0);
				if(s.count({x-2, y}))
					process(x-2, y, 2);
			}
		} else {
			if(s.count({x+2, y})) {
				process(x+2, y, 0);
				if(s.count({x,y+2}))
					process(x, y+2, 3);
				if(s.count({x,y-2}))
					process(x, y-2, 1);
				if(s.count({x-2, y}))
					process(x-2, y, 2);
			} else {
				if(s.count({x-2,y}))
					process(x-2, y, 2);
				if(s.count({x, y+2}))
					process(x, y+2, 3);
				if(s.count({x, y-2}))
					process(x, y-2, 1);
			}
		}
	}
	if(cnt < n)
		return 0;
	build(u,v,a,b);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 178 ms 18076 KB Output is correct
10 Correct 12 ms 2332 KB Output is correct
11 Correct 80 ms 10132 KB Output is correct
12 Correct 19 ms 3156 KB Output is correct
13 Correct 41 ms 6892 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 199 ms 18100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 178 ms 18076 KB Output is correct
10 Correct 12 ms 2332 KB Output is correct
11 Correct 80 ms 10132 KB Output is correct
12 Correct 19 ms 3156 KB Output is correct
13 Correct 41 ms 6892 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 199 ms 18100 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 292 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 458 ms 36368 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 724 KB Output is correct
27 Correct 3 ms 852 KB Output is correct
28 Correct 150 ms 14800 KB Output is correct
29 Correct 244 ms 22000 KB Output is correct
30 Correct 347 ms 29344 KB Output is correct
31 Correct 454 ms 36340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 296 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 206 ms 18292 KB Output is correct
46 Correct 368 ms 26104 KB Output is correct
47 Correct 313 ms 26288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 178 ms 18076 KB Output is correct
10 Correct 12 ms 2332 KB Output is correct
11 Correct 80 ms 10132 KB Output is correct
12 Correct 19 ms 3156 KB Output is correct
13 Correct 41 ms 6892 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 199 ms 18100 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 292 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 458 ms 36368 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 724 KB Output is correct
27 Correct 3 ms 852 KB Output is correct
28 Correct 150 ms 14800 KB Output is correct
29 Correct 244 ms 22000 KB Output is correct
30 Correct 347 ms 29344 KB Output is correct
31 Correct 454 ms 36340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 296 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 206 ms 18292 KB Output is correct
46 Correct 368 ms 26104 KB Output is correct
47 Correct 313 ms 26288 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 296 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Incorrect 1 ms 212 KB Tree @(3, 3) appears more than once: for edges on positions 3 and 4
52 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 178 ms 18076 KB Output is correct
10 Correct 12 ms 2332 KB Output is correct
11 Correct 80 ms 10132 KB Output is correct
12 Correct 19 ms 3156 KB Output is correct
13 Correct 41 ms 6892 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 199 ms 18100 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 459 ms 36068 KB Output is correct
21 Correct 479 ms 35988 KB Output is correct
22 Correct 477 ms 35840 KB Output is correct
23 Correct 389 ms 30308 KB Output is correct
24 Correct 271 ms 26024 KB Output is correct
25 Correct 294 ms 25972 KB Output is correct
26 Correct 264 ms 26000 KB Output is correct
27 Correct 444 ms 35368 KB Output is correct
28 Correct 446 ms 35392 KB Output is correct
29 Correct 677 ms 35376 KB Output is correct
30 Correct 658 ms 35412 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Incorrect 27 ms 3232 KB Tree @(185789, 20625) appears more than once: for edges on positions 3 and 4
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 178 ms 18076 KB Output is correct
10 Correct 12 ms 2332 KB Output is correct
11 Correct 80 ms 10132 KB Output is correct
12 Correct 19 ms 3156 KB Output is correct
13 Correct 41 ms 6892 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 199 ms 18100 KB Output is correct
17 Correct 465 ms 35816 KB Output is correct
18 Incorrect 448 ms 35892 KB Tree @(50001, 50003) appears more than once: for edges on positions 80338 and 80339
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 178 ms 18076 KB Output is correct
10 Correct 12 ms 2332 KB Output is correct
11 Correct 80 ms 10132 KB Output is correct
12 Correct 19 ms 3156 KB Output is correct
13 Correct 41 ms 6892 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 199 ms 18100 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 292 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 458 ms 36368 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 724 KB Output is correct
27 Correct 3 ms 852 KB Output is correct
28 Correct 150 ms 14800 KB Output is correct
29 Correct 244 ms 22000 KB Output is correct
30 Correct 347 ms 29344 KB Output is correct
31 Correct 454 ms 36340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 296 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 206 ms 18292 KB Output is correct
46 Correct 368 ms 26104 KB Output is correct
47 Correct 313 ms 26288 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 296 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Incorrect 1 ms 212 KB Tree @(3, 3) appears more than once: for edges on positions 3 and 4
52 Halted 0 ms 0 KB -