Submission #1047796

# Submission time Handle Problem Language Result Execution time Memory
1047796 2024-08-07T16:02:24 Z vjudge1 Fountain Parks (IOI21_parks) C++17
45 / 100
275 ms 49996 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;

#define ar array

const int dir[4][2] = {{2, 0}, {-2, 0}, {0, 2}, {0, -2}};

const int N = 3e5 + 20;

int X[N], Y[N];
map<ar<int, 2>, int > mp;

vector<int> U, V, A, B;
bool vis[N];

void dfs(int x){
	vis[x] = 1;
	for(int i = 0;i < 4;i++){
		if(mp.count(ar<int, 2>{X[x] + dir[i][0], Y[x] + dir[i][1]})){
			int u = mp[ar<int, 2>{X[x] + dir[i][0], Y[x] + dir[i][1]}];
			if(vis[u])continue;
			U.push_back(x);
			V.push_back(u);
			if(X[x] == X[u]){
				B.push_back({Y[x] + (Y[x] < Y[u] ? 1 : -1)});
				if((X[u] + Y[u]) & 2)A.push_back({X[x] + (Y[x] > Y[u] ? 1 : -1)});
				else A.push_back({X[x] + (Y[x] < Y[u] ? 1 : -1)});
			}else{
				A.push_back({X[x] + (X[x] < X[u] ? 1 : -1)});
				if((X[u] + Y[u]) & 2)B.push_back({Y[x] + (X[x] < X[u] ? 1 : -1)});
				else B.push_back({Y[x] + (X[x] > X[u] ? 1 : -1)});
			}
			dfs(u);
		}
	}
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
	int n = x.size();
	for(int i = 0;i < n;i++)X[i] = x[i], Y[i] = y[i];
    for(int i = 0;i < n;i++)mp[{x[i], y[i]}] = i;
	dfs(0);
	for(int i = 0;i < n;i++){
		if(!vis[i]){
			return 0;
		}
	}
	

	build(U, V, A, B);
	return 1;
	
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 100 ms 25180 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Correct 47 ms 15248 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 83 ms 20700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 100 ms 25180 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Correct 47 ms 15248 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 83 ms 20700 KB Output is correct
17 Incorrect 0 ms 2396 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 2
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 100 ms 25180 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Correct 47 ms 15248 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 83 ms 20700 KB Output is correct
17 Incorrect 0 ms 2396 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 2
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 100 ms 25180 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Correct 47 ms 15248 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 83 ms 20700 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 235 ms 49592 KB Output is correct
21 Correct 236 ms 45228 KB Output is correct
22 Correct 250 ms 42920 KB Output is correct
23 Correct 169 ms 36020 KB Output is correct
24 Correct 78 ms 18148 KB Output is correct
25 Correct 106 ms 18260 KB Output is correct
26 Correct 79 ms 18284 KB Output is correct
27 Correct 178 ms 27964 KB Output is correct
28 Correct 187 ms 27864 KB Output is correct
29 Correct 275 ms 27948 KB Output is correct
30 Correct 239 ms 27904 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 11 ms 5168 KB Output is correct
33 Correct 35 ms 10068 KB Output is correct
34 Correct 232 ms 46044 KB Output is correct
35 Correct 5 ms 3420 KB Output is correct
36 Correct 19 ms 6740 KB Output is correct
37 Correct 39 ms 10552 KB Output is correct
38 Correct 76 ms 13056 KB Output is correct
39 Correct 96 ms 16580 KB Output is correct
40 Correct 126 ms 20436 KB Output is correct
41 Correct 165 ms 24712 KB Output is correct
42 Correct 209 ms 28312 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 0 ms 2396 KB Output is correct
47 Correct 0 ms 2396 KB Output is correct
48 Correct 0 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 0 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 0 ms 2396 KB Output is correct
54 Correct 2 ms 2652 KB Output is correct
55 Correct 1 ms 2652 KB Output is correct
56 Correct 90 ms 21848 KB Output is correct
57 Correct 128 ms 31192 KB Output is correct
58 Correct 127 ms 30864 KB Output is correct
59 Correct 0 ms 2396 KB Output is correct
60 Correct 0 ms 2396 KB Output is correct
61 Correct 0 ms 2396 KB Output is correct
62 Correct 172 ms 43380 KB Output is correct
63 Correct 192 ms 43684 KB Output is correct
64 Correct 181 ms 46000 KB Output is correct
65 Correct 2 ms 2908 KB Output is correct
66 Correct 4 ms 3164 KB Output is correct
67 Correct 87 ms 18824 KB Output is correct
68 Correct 136 ms 29612 KB Output is correct
69 Correct 189 ms 35384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 100 ms 25180 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Correct 47 ms 15248 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 83 ms 20700 KB Output is correct
17 Correct 197 ms 49964 KB Output is correct
18 Correct 198 ms 41036 KB Output is correct
19 Correct 206 ms 49996 KB Output is correct
20 Correct 263 ms 39688 KB Output is correct
21 Correct 208 ms 32848 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 26 ms 7704 KB Output is correct
24 Correct 11 ms 4696 KB Output is correct
25 Correct 30 ms 8776 KB Output is correct
26 Correct 50 ms 12708 KB Output is correct
27 Correct 103 ms 20036 KB Output is correct
28 Correct 138 ms 24492 KB Output is correct
29 Correct 184 ms 29192 KB Output is correct
30 Correct 213 ms 33644 KB Output is correct
31 Correct 239 ms 37704 KB Output is correct
32 Correct 214 ms 44940 KB Output is correct
33 Correct 187 ms 49580 KB Output is correct
34 Correct 2 ms 3164 KB Output is correct
35 Correct 5 ms 3420 KB Output is correct
36 Correct 84 ms 20856 KB Output is correct
37 Correct 141 ms 30672 KB Output is correct
38 Correct 199 ms 40360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 100 ms 25180 KB Output is correct
10 Correct 7 ms 4956 KB Output is correct
11 Correct 47 ms 15248 KB Output is correct
12 Correct 10 ms 6232 KB Output is correct
13 Correct 22 ms 9820 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 83 ms 20700 KB Output is correct
17 Incorrect 0 ms 2396 KB Tree @(3, 3) appears more than once: for edges on positions 0 and 2
18 Halted 0 ms 0 KB -