Submission #1052907

# Submission time Handle Problem Language Result Execution time Memory
1052907 2024-08-11T05:51:32 Z ReLice Fountain Parks (IOI21_parks) C++17
55 / 100
402 ms 92980 KB
#include "parks.h"
#include <bits/stdc++.h>
#define pb push_back
#define ll int
#define ins insert
#define sz size()
#define vll vector<ll>
#define sc second
using namespace std;
const int N=2e5+5;
const int inf=1e9;
map<pair<ll,ll>, ll> f;
vll xx, yy;

ll xd[4] = {-2, 2, 0, 0}, yd[4] = {0, 0, -2, 2};
ll bx[2][4] = {{-1, 1,  1, -1}, {-1,  1, -1,  1}};
ll by[2][4] = {{-1, 1, -1,  1}, { 1, -1, -1,  1}};

set<pair<ll,ll>> vis;
vll v,u,a,b;
ll n,c;
bool ok(ll x,ll y){
	bool free = (vis.find({x, y}) == vis.end());
	if(x % 2) return free;
	return free && f[{x,y}];
}
void dfs(ll x, ll y){
	vis.ins({x, y});
	c++;
	for(ll i=3;i>=0;i--){
		ll nx = x + xd[i], ny = y + yd[i];
		
		ll p = (x + y) / 2 % 2;
		ll aa = x + bx[p][i], bb = y + by[p][i];
		
		if(!ok(nx, ny) || !ok(aa, bb)) continue;
		
		v.pb(f[{x,y}]-1);
		u.pb(f[{nx,ny}]-1);
		a.pb(aa);
		b.pb(bb);
		
		vis.ins({aa, bb});
		
		dfs(nx, ny);
	}
}
int construct_roads(vector<int> X, vector<int> Y) {
	n=X.size();
	
	for(int i=0;i<(int)X.size();i++){
		f[{X[i], Y[i]}] = i + 1;
	}
	
	xx.pb(0);
	yy.pb(0);
	for(auto i : X) xx.pb(i);
	for(auto i : Y) yy.pb(i);
	
	dfs(xx[1], yy[1]);
	
	if((ll)u.size() != n - 1) return 0;
	
	build(u, v, a, b);
	
	return 1;
}











# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 176 ms 45708 KB Output is correct
10 Correct 12 ms 5208 KB Output is correct
11 Correct 80 ms 25172 KB Output is correct
12 Correct 18 ms 7512 KB Output is correct
13 Correct 41 ms 14460 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 164 ms 41284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 176 ms 45708 KB Output is correct
10 Correct 12 ms 5208 KB Output is correct
11 Correct 80 ms 25172 KB Output is correct
12 Correct 18 ms 7512 KB Output is correct
13 Correct 41 ms 14460 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 164 ms 41284 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 374 ms 68308 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 856 KB Output is correct
26 Correct 2 ms 1004 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 125 ms 28104 KB Output is correct
29 Correct 188 ms 40272 KB Output is correct
30 Correct 268 ms 55116 KB Output is correct
31 Correct 367 ms 67152 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 860 KB Output is correct
45 Correct 164 ms 38572 KB Output is correct
46 Correct 240 ms 56660 KB Output is correct
47 Correct 241 ms 56136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 176 ms 45708 KB Output is correct
10 Correct 12 ms 5208 KB Output is correct
11 Correct 80 ms 25172 KB Output is correct
12 Correct 18 ms 7512 KB Output is correct
13 Correct 41 ms 14460 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 164 ms 41284 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 374 ms 68308 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 856 KB Output is correct
26 Correct 2 ms 1004 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 125 ms 28104 KB Output is correct
29 Correct 188 ms 40272 KB Output is correct
30 Correct 268 ms 55116 KB Output is correct
31 Correct 367 ms 67152 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 860 KB Output is correct
45 Correct 164 ms 38572 KB Output is correct
46 Correct 240 ms 56660 KB Output is correct
47 Correct 241 ms 56136 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Incorrect 314 ms 62540 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 176 ms 45708 KB Output is correct
10 Correct 12 ms 5208 KB Output is correct
11 Correct 80 ms 25172 KB Output is correct
12 Correct 18 ms 7512 KB Output is correct
13 Correct 41 ms 14460 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 164 ms 41284 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 345 ms 80324 KB Output is correct
21 Correct 341 ms 76064 KB Output is correct
22 Correct 331 ms 73448 KB Output is correct
23 Correct 284 ms 72520 KB Output is correct
24 Correct 77 ms 18384 KB Output is correct
25 Correct 73 ms 18380 KB Output is correct
26 Correct 81 ms 18160 KB Output is correct
27 Correct 286 ms 58708 KB Output is correct
28 Correct 267 ms 58752 KB Output is correct
29 Correct 361 ms 58704 KB Output is correct
30 Correct 402 ms 58736 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 19 ms 5404 KB Output is correct
33 Correct 36 ms 9276 KB Output is correct
34 Correct 341 ms 76824 KB Output is correct
35 Correct 7 ms 1884 KB Output is correct
36 Correct 27 ms 6144 KB Output is correct
37 Correct 44 ms 10576 KB Output is correct
38 Correct 114 ms 22316 KB Output is correct
39 Correct 167 ms 30248 KB Output is correct
40 Correct 232 ms 38764 KB Output is correct
41 Correct 277 ms 46984 KB Output is correct
42 Correct 329 ms 55020 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 860 KB Output is correct
55 Correct 1 ms 860 KB Output is correct
56 Correct 157 ms 38552 KB Output is correct
57 Correct 240 ms 56616 KB Output is correct
58 Correct 239 ms 56140 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 390 ms 80400 KB Output is correct
63 Correct 359 ms 80808 KB Output is correct
64 Correct 379 ms 82756 KB Output is correct
65 Correct 3 ms 1116 KB Output is correct
66 Correct 4 ms 1372 KB Output is correct
67 Correct 156 ms 34108 KB Output is correct
68 Correct 285 ms 53828 KB Output is correct
69 Correct 399 ms 68048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 176 ms 45708 KB Output is correct
10 Correct 12 ms 5208 KB Output is correct
11 Correct 80 ms 25172 KB Output is correct
12 Correct 18 ms 7512 KB Output is correct
13 Correct 41 ms 14460 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 164 ms 41284 KB Output is correct
17 Correct 380 ms 92980 KB Output is correct
18 Correct 390 ms 84204 KB Output is correct
19 Correct 366 ms 80712 KB Output is correct
20 Correct 294 ms 59948 KB Output is correct
21 Correct 286 ms 62908 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 46 ms 10492 KB Output is correct
24 Correct 16 ms 3676 KB Output is correct
25 Correct 44 ms 8532 KB Output is correct
26 Correct 66 ms 12704 KB Output is correct
27 Correct 169 ms 31264 KB Output is correct
28 Correct 216 ms 38952 KB Output is correct
29 Correct 285 ms 46972 KB Output is correct
30 Correct 311 ms 54128 KB Output is correct
31 Correct 329 ms 62184 KB Output is correct
32 Correct 364 ms 76108 KB Output is correct
33 Correct 389 ms 86608 KB Output is correct
34 Correct 3 ms 1368 KB Output is correct
35 Correct 5 ms 1884 KB Output is correct
36 Correct 151 ms 34244 KB Output is correct
37 Correct 246 ms 51780 KB Output is correct
38 Correct 340 ms 68940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 176 ms 45708 KB Output is correct
10 Correct 12 ms 5208 KB Output is correct
11 Correct 80 ms 25172 KB Output is correct
12 Correct 18 ms 7512 KB Output is correct
13 Correct 41 ms 14460 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 164 ms 41284 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 374 ms 68308 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 2 ms 856 KB Output is correct
26 Correct 2 ms 1004 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 125 ms 28104 KB Output is correct
29 Correct 188 ms 40272 KB Output is correct
30 Correct 268 ms 55116 KB Output is correct
31 Correct 367 ms 67152 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 860 KB Output is correct
44 Correct 1 ms 860 KB Output is correct
45 Correct 164 ms 38572 KB Output is correct
46 Correct 240 ms 56660 KB Output is correct
47 Correct 241 ms 56136 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Incorrect 314 ms 62540 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -