Submission #1052901

# Submission time Handle Problem Language Result Execution time Memory
1052901 2024-08-11T05:47:37 Z ReLice Fountain Parks (IOI21_parks) C++17
55 / 100
415 ms 93000 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 1 ms 344 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 171 ms 45876 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 85 ms 25344 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 42 ms 14548 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 167 ms 41288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 171 ms 45876 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 85 ms 25344 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 42 ms 14548 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 167 ms 41288 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 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 1 ms 348 KB Output is correct
23 Correct 376 ms 68192 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 860 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 122 ms 28104 KB Output is correct
29 Correct 189 ms 40272 KB Output is correct
30 Correct 265 ms 55124 KB Output is correct
31 Correct 349 ms 67152 KB Output is correct
32 Correct 0 ms 348 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 160 ms 38668 KB Output is correct
46 Correct 272 ms 56656 KB Output is correct
47 Correct 253 ms 56088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 171 ms 45876 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 85 ms 25344 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 42 ms 14548 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 167 ms 41288 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 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 1 ms 348 KB Output is correct
23 Correct 376 ms 68192 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 860 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 122 ms 28104 KB Output is correct
29 Correct 189 ms 40272 KB Output is correct
30 Correct 265 ms 55124 KB Output is correct
31 Correct 349 ms 67152 KB Output is correct
32 Correct 0 ms 348 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 160 ms 38668 KB Output is correct
46 Correct 272 ms 56656 KB Output is correct
47 Correct 253 ms 56088 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 324 ms 62684 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 171 ms 45876 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 85 ms 25344 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 42 ms 14548 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 167 ms 41288 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 365 ms 80340 KB Output is correct
21 Correct 340 ms 76068 KB Output is correct
22 Correct 361 ms 73452 KB Output is correct
23 Correct 272 ms 72516 KB Output is correct
24 Correct 76 ms 18376 KB Output is correct
25 Correct 77 ms 18380 KB Output is correct
26 Correct 79 ms 18160 KB Output is correct
27 Correct 276 ms 58700 KB Output is correct
28 Correct 287 ms 58776 KB Output is correct
29 Correct 389 ms 58696 KB Output is correct
30 Correct 393 ms 58668 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 22 ms 5412 KB Output is correct
33 Correct 33 ms 9268 KB Output is correct
34 Correct 335 ms 76760 KB Output is correct
35 Correct 7 ms 1880 KB Output is correct
36 Correct 25 ms 6340 KB Output is correct
37 Correct 46 ms 10724 KB Output is correct
38 Correct 116 ms 22384 KB Output is correct
39 Correct 179 ms 30248 KB Output is correct
40 Correct 226 ms 38740 KB Output is correct
41 Correct 270 ms 47008 KB Output is correct
42 Correct 325 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 360 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 1 ms 860 KB Output is correct
55 Correct 1 ms 860 KB Output is correct
56 Correct 155 ms 38592 KB Output is correct
57 Correct 241 ms 56700 KB Output is correct
58 Correct 251 ms 56136 KB Output is correct
59 Correct 0 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 415 ms 80396 KB Output is correct
63 Correct 359 ms 80720 KB Output is correct
64 Correct 358 ms 82756 KB Output is correct
65 Correct 3 ms 1116 KB Output is correct
66 Correct 4 ms 1520 KB Output is correct
67 Correct 152 ms 34008 KB Output is correct
68 Correct 255 ms 53884 KB Output is correct
69 Correct 375 ms 67920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 171 ms 45876 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 85 ms 25344 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 42 ms 14548 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 167 ms 41288 KB Output is correct
17 Correct 354 ms 93000 KB Output is correct
18 Correct 373 ms 84404 KB Output is correct
19 Correct 333 ms 80808 KB Output is correct
20 Correct 269 ms 59980 KB Output is correct
21 Correct 271 ms 63044 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 40 ms 10496 KB Output is correct
24 Correct 14 ms 3656 KB Output is correct
25 Correct 32 ms 8404 KB Output is correct
26 Correct 53 ms 12628 KB Output is correct
27 Correct 166 ms 31256 KB Output is correct
28 Correct 185 ms 38856 KB Output is correct
29 Correct 226 ms 46976 KB Output is correct
30 Correct 275 ms 54344 KB Output is correct
31 Correct 332 ms 62192 KB Output is correct
32 Correct 349 ms 76108 KB Output is correct
33 Correct 371 ms 86644 KB Output is correct
34 Correct 5 ms 1368 KB Output is correct
35 Correct 5 ms 1920 KB Output is correct
36 Correct 145 ms 34120 KB Output is correct
37 Correct 246 ms 51784 KB Output is correct
38 Correct 334 ms 68940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 171 ms 45876 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 85 ms 25344 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 42 ms 14548 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 167 ms 41288 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 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 1 ms 348 KB Output is correct
23 Correct 376 ms 68192 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 860 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 122 ms 28104 KB Output is correct
29 Correct 189 ms 40272 KB Output is correct
30 Correct 265 ms 55124 KB Output is correct
31 Correct 349 ms 67152 KB Output is correct
32 Correct 0 ms 348 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 160 ms 38668 KB Output is correct
46 Correct 272 ms 56656 KB Output is correct
47 Correct 253 ms 56088 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 324 ms 62684 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -