Submission #1052888

# Submission time Handle Problem Language Result Execution time Memory
1052888 2024-08-11T05:32:11 Z ReLice Fountain Parks (IOI21_parks) C++17
55 / 100
410 ms 93012 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] = {0, 2, 0, -2}, yd[4] = {2, 0, -2, 0};
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=0;i<4;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 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 169 ms 45688 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 80 ms 25292 KB Output is correct
12 Correct 20 ms 7516 KB Output is correct
13 Correct 41 ms 14640 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 175 ms 41404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 169 ms 45688 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 80 ms 25292 KB Output is correct
12 Correct 20 ms 7516 KB Output is correct
13 Correct 41 ms 14640 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 175 ms 41404 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 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 357 ms 68248 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 860 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 116 ms 28092 KB Output is correct
29 Correct 191 ms 40244 KB Output is correct
30 Correct 281 ms 55068 KB Output is correct
31 Correct 356 ms 67192 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 344 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 396 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 2 ms 856 KB Output is correct
45 Correct 184 ms 38588 KB Output is correct
46 Correct 250 ms 56656 KB Output is correct
47 Correct 241 ms 56160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 169 ms 45688 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 80 ms 25292 KB Output is correct
12 Correct 20 ms 7516 KB Output is correct
13 Correct 41 ms 14640 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 175 ms 41404 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 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 357 ms 68248 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 860 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 116 ms 28092 KB Output is correct
29 Correct 191 ms 40244 KB Output is correct
30 Correct 281 ms 55068 KB Output is correct
31 Correct 356 ms 67192 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 344 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 396 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 2 ms 856 KB Output is correct
45 Correct 184 ms 38588 KB Output is correct
46 Correct 250 ms 56656 KB Output is correct
47 Correct 241 ms 56160 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 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Incorrect 314 ms 62736 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 169 ms 45688 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 80 ms 25292 KB Output is correct
12 Correct 20 ms 7516 KB Output is correct
13 Correct 41 ms 14640 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 175 ms 41404 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 349 ms 80392 KB Output is correct
21 Correct 333 ms 76008 KB Output is correct
22 Correct 335 ms 73484 KB Output is correct
23 Correct 282 ms 72588 KB Output is correct
24 Correct 80 ms 18384 KB Output is correct
25 Correct 87 ms 18256 KB Output is correct
26 Correct 70 ms 18380 KB Output is correct
27 Correct 281 ms 58712 KB Output is correct
28 Correct 265 ms 58600 KB Output is correct
29 Correct 402 ms 59008 KB Output is correct
30 Correct 410 ms 58816 KB Output is correct
31 Correct 0 ms 600 KB Output is correct
32 Correct 19 ms 5468 KB Output is correct
33 Correct 37 ms 9420 KB Output is correct
34 Correct 328 ms 76784 KB Output is correct
35 Correct 7 ms 1884 KB Output is correct
36 Correct 25 ms 6188 KB Output is correct
37 Correct 44 ms 10572 KB Output is correct
38 Correct 114 ms 22248 KB Output is correct
39 Correct 177 ms 30216 KB Output is correct
40 Correct 221 ms 38928 KB Output is correct
41 Correct 283 ms 46968 KB Output is correct
42 Correct 320 ms 55024 KB Output is correct
43 Correct 0 ms 348 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 344 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 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 152 ms 38640 KB Output is correct
57 Correct 244 ms 56656 KB Output is correct
58 Correct 283 ms 56136 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 371 ms 80316 KB Output is correct
63 Correct 370 ms 80784 KB Output is correct
64 Correct 360 ms 82756 KB Output is correct
65 Correct 3 ms 1112 KB Output is correct
66 Correct 4 ms 1368 KB Output is correct
67 Correct 149 ms 34120 KB Output is correct
68 Correct 264 ms 53792 KB Output is correct
69 Correct 345 ms 67920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 169 ms 45688 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 80 ms 25292 KB Output is correct
12 Correct 20 ms 7516 KB Output is correct
13 Correct 41 ms 14640 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 175 ms 41404 KB Output is correct
17 Correct 371 ms 93012 KB Output is correct
18 Correct 359 ms 84352 KB Output is correct
19 Correct 340 ms 80612 KB Output is correct
20 Correct 284 ms 63564 KB Output is correct
21 Correct 267 ms 65912 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 40 ms 10776 KB Output is correct
24 Correct 17 ms 3932 KB Output is correct
25 Correct 33 ms 8788 KB Output is correct
26 Correct 54 ms 12904 KB Output is correct
27 Correct 148 ms 32792 KB Output is correct
28 Correct 195 ms 40904 KB Output is correct
29 Correct 232 ms 49528 KB Output is correct
30 Correct 289 ms 57252 KB Output is correct
31 Correct 348 ms 65772 KB Output is correct
32 Correct 352 ms 76116 KB Output is correct
33 Correct 375 ms 86780 KB Output is correct
34 Correct 4 ms 1372 KB Output is correct
35 Correct 6 ms 1884 KB Output is correct
36 Correct 182 ms 34304 KB Output is correct
37 Correct 236 ms 52012 KB Output is correct
38 Correct 345 ms 68772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 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 169 ms 45688 KB Output is correct
10 Correct 14 ms 5212 KB Output is correct
11 Correct 80 ms 25292 KB Output is correct
12 Correct 20 ms 7516 KB Output is correct
13 Correct 41 ms 14640 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 175 ms 41404 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 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 357 ms 68248 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 860 KB Output is correct
27 Correct 2 ms 860 KB Output is correct
28 Correct 116 ms 28092 KB Output is correct
29 Correct 191 ms 40244 KB Output is correct
30 Correct 281 ms 55068 KB Output is correct
31 Correct 356 ms 67192 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 344 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 396 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 2 ms 856 KB Output is correct
45 Correct 184 ms 38588 KB Output is correct
46 Correct 250 ms 56656 KB Output is correct
47 Correct 241 ms 56160 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 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Incorrect 314 ms 62736 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -