답안 #565852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
565852 2022-05-21T12:22:26 Z PiejanVDC 분수 공원 (IOI21_parks) C++17
15 / 100
738 ms 36740 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;
	queue<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.front().first;
		int d = st.front().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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 308 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 219 ms 18488 KB Output is correct
10 Correct 12 ms 2316 KB Output is correct
11 Correct 83 ms 10140 KB Output is correct
12 Correct 22 ms 3176 KB Output is correct
13 Correct 44 ms 6932 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 211 ms 18392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 308 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 219 ms 18488 KB Output is correct
10 Correct 12 ms 2316 KB Output is correct
11 Correct 83 ms 10140 KB Output is correct
12 Correct 22 ms 3176 KB Output is correct
13 Correct 44 ms 6932 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 211 ms 18392 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 478 ms 36112 KB Output is correct
24 Correct 1 ms 212 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 752 KB Output is correct
28 Correct 156 ms 14860 KB Output is correct
29 Correct 306 ms 22060 KB Output is correct
30 Correct 360 ms 29320 KB Output is correct
31 Correct 479 ms 36296 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 252 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 1 ms 212 KB Output is correct
40 Correct 1 ms 296 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 3 ms 692 KB Output is correct
45 Correct 228 ms 18520 KB Output is correct
46 Correct 337 ms 26616 KB Output is correct
47 Correct 337 ms 26600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 308 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 219 ms 18488 KB Output is correct
10 Correct 12 ms 2316 KB Output is correct
11 Correct 83 ms 10140 KB Output is correct
12 Correct 22 ms 3176 KB Output is correct
13 Correct 44 ms 6932 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 211 ms 18392 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 478 ms 36112 KB Output is correct
24 Correct 1 ms 212 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 752 KB Output is correct
28 Correct 156 ms 14860 KB Output is correct
29 Correct 306 ms 22060 KB Output is correct
30 Correct 360 ms 29320 KB Output is correct
31 Correct 479 ms 36296 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 252 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 1 ms 212 KB Output is correct
40 Correct 1 ms 296 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 3 ms 692 KB Output is correct
45 Correct 228 ms 18520 KB Output is correct
46 Correct 337 ms 26616 KB Output is correct
47 Correct 337 ms 26600 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 300 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 300 KB Output is correct
55 Incorrect 517 ms 36344 KB Tree @(3, 95051) appears more than once: for edges on positions 8 and 9
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 308 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 219 ms 18488 KB Output is correct
10 Correct 12 ms 2316 KB Output is correct
11 Correct 83 ms 10140 KB Output is correct
12 Correct 22 ms 3176 KB Output is correct
13 Correct 44 ms 6932 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 211 ms 18392 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 438 ms 36584 KB Output is correct
21 Correct 496 ms 36244 KB Output is correct
22 Correct 501 ms 36424 KB Output is correct
23 Correct 405 ms 31060 KB Output is correct
24 Correct 270 ms 26484 KB Output is correct
25 Correct 267 ms 26484 KB Output is correct
26 Correct 272 ms 26444 KB Output is correct
27 Correct 662 ms 36072 KB Output is correct
28 Correct 675 ms 36016 KB Output is correct
29 Correct 738 ms 35964 KB Output is correct
30 Correct 731 ms 35956 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Incorrect 29 ms 3256 KB Tree @(185789, 20625) appears more than once: for edges on positions 4 and 5
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 308 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 219 ms 18488 KB Output is correct
10 Correct 12 ms 2316 KB Output is correct
11 Correct 83 ms 10140 KB Output is correct
12 Correct 22 ms 3176 KB Output is correct
13 Correct 44 ms 6932 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 211 ms 18392 KB Output is correct
17 Correct 504 ms 36104 KB Output is correct
18 Correct 512 ms 36180 KB Output is correct
19 Correct 520 ms 36740 KB Output is correct
20 Incorrect 644 ms 35488 KB Tree @(265, 883) appears more than once: for edges on positions 9 and 10
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 412 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 308 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 219 ms 18488 KB Output is correct
10 Correct 12 ms 2316 KB Output is correct
11 Correct 83 ms 10140 KB Output is correct
12 Correct 22 ms 3176 KB Output is correct
13 Correct 44 ms 6932 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 211 ms 18392 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 478 ms 36112 KB Output is correct
24 Correct 1 ms 212 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 752 KB Output is correct
28 Correct 156 ms 14860 KB Output is correct
29 Correct 306 ms 22060 KB Output is correct
30 Correct 360 ms 29320 KB Output is correct
31 Correct 479 ms 36296 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 252 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 1 ms 212 KB Output is correct
40 Correct 1 ms 296 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 3 ms 692 KB Output is correct
45 Correct 228 ms 18520 KB Output is correct
46 Correct 337 ms 26616 KB Output is correct
47 Correct 337 ms 26600 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 300 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 300 KB Output is correct
55 Incorrect 517 ms 36344 KB Tree @(3, 95051) appears more than once: for edges on positions 8 and 9
56 Halted 0 ms 0 KB -