답안 #1052881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052881 2024-08-11T05:26:58 Z ReLice 분수 공원 (IOI21_parks) C++17
55 / 100
414 ms 92840 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(c != n) return 0;
	
	build(u, v, a, b);
	
	return 1;
}











# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 198 ms 45680 KB Output is correct
10 Correct 13 ms 5212 KB Output is correct
11 Correct 83 ms 25224 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 41 ms 14668 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 169 ms 41268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 198 ms 45680 KB Output is correct
10 Correct 13 ms 5212 KB Output is correct
11 Correct 83 ms 25224 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 41 ms 14668 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 169 ms 41268 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 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 381 ms 68268 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 118 ms 27968 KB Output is correct
29 Correct 189 ms 40280 KB Output is correct
30 Correct 280 ms 55116 KB Output is correct
31 Correct 355 ms 67144 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 2 ms 860 KB Output is correct
44 Correct 1 ms 856 KB Output is correct
45 Correct 156 ms 38472 KB Output is correct
46 Correct 248 ms 56776 KB Output is correct
47 Correct 247 ms 56136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 198 ms 45680 KB Output is correct
10 Correct 13 ms 5212 KB Output is correct
11 Correct 83 ms 25224 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 41 ms 14668 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 169 ms 41268 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 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 381 ms 68268 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 118 ms 27968 KB Output is correct
29 Correct 189 ms 40280 KB Output is correct
30 Correct 280 ms 55116 KB Output is correct
31 Correct 355 ms 67144 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 2 ms 860 KB Output is correct
44 Correct 1 ms 856 KB Output is correct
45 Correct 156 ms 38472 KB Output is correct
46 Correct 248 ms 56776 KB Output is correct
47 Correct 247 ms 56136 KB Output is correct
48 Correct 0 ms 600 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 322 ms 62572 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 198 ms 45680 KB Output is correct
10 Correct 13 ms 5212 KB Output is correct
11 Correct 83 ms 25224 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 41 ms 14668 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 169 ms 41268 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 373 ms 80372 KB Output is correct
21 Correct 360 ms 75888 KB Output is correct
22 Correct 343 ms 73556 KB Output is correct
23 Correct 297 ms 72520 KB Output is correct
24 Correct 76 ms 18380 KB Output is correct
25 Correct 76 ms 18380 KB Output is correct
26 Correct 85 ms 18304 KB Output is correct
27 Correct 272 ms 58704 KB Output is correct
28 Correct 282 ms 58788 KB Output is correct
29 Correct 398 ms 58700 KB Output is correct
30 Correct 414 ms 58708 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 19 ms 5520 KB Output is correct
33 Correct 33 ms 9424 KB Output is correct
34 Correct 340 ms 76780 KB Output is correct
35 Correct 9 ms 2140 KB Output is correct
36 Correct 24 ms 6288 KB Output is correct
37 Correct 56 ms 10528 KB Output is correct
38 Correct 116 ms 22520 KB Output is correct
39 Correct 183 ms 30364 KB Output is correct
40 Correct 221 ms 38872 KB Output is correct
41 Correct 271 ms 46876 KB Output is correct
42 Correct 337 ms 54908 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 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 175 ms 38464 KB Output is correct
57 Correct 247 ms 56732 KB Output is correct
58 Correct 246 ms 55916 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 373 ms 80304 KB Output is correct
63 Correct 377 ms 80720 KB Output is correct
64 Correct 359 ms 82756 KB Output is correct
65 Correct 3 ms 1116 KB Output is correct
66 Correct 3 ms 1372 KB Output is correct
67 Correct 159 ms 34096 KB Output is correct
68 Correct 259 ms 53828 KB Output is correct
69 Correct 371 ms 68020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 198 ms 45680 KB Output is correct
10 Correct 13 ms 5212 KB Output is correct
11 Correct 83 ms 25224 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 41 ms 14668 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 169 ms 41268 KB Output is correct
17 Correct 372 ms 92840 KB Output is correct
18 Correct 344 ms 84200 KB Output is correct
19 Correct 362 ms 80628 KB Output is correct
20 Correct 292 ms 63572 KB Output is correct
21 Correct 278 ms 65864 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 45 ms 10852 KB Output is correct
24 Correct 14 ms 3928 KB Output is correct
25 Correct 33 ms 8700 KB Output is correct
26 Correct 52 ms 12920 KB Output is correct
27 Correct 149 ms 32804 KB Output is correct
28 Correct 219 ms 40900 KB Output is correct
29 Correct 255 ms 49636 KB Output is correct
30 Correct 291 ms 57160 KB Output is correct
31 Correct 342 ms 65748 KB Output is correct
32 Correct 353 ms 75992 KB Output is correct
33 Correct 386 ms 86608 KB Output is correct
34 Correct 3 ms 1372 KB Output is correct
35 Correct 5 ms 1880 KB Output is correct
36 Correct 161 ms 34276 KB Output is correct
37 Correct 253 ms 52036 KB Output is correct
38 Correct 336 ms 68940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 198 ms 45680 KB Output is correct
10 Correct 13 ms 5212 KB Output is correct
11 Correct 83 ms 25224 KB Output is correct
12 Correct 19 ms 7516 KB Output is correct
13 Correct 41 ms 14668 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 169 ms 41268 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 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 381 ms 68268 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 118 ms 27968 KB Output is correct
29 Correct 189 ms 40280 KB Output is correct
30 Correct 280 ms 55116 KB Output is correct
31 Correct 355 ms 67144 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 2 ms 860 KB Output is correct
44 Correct 1 ms 856 KB Output is correct
45 Correct 156 ms 38472 KB Output is correct
46 Correct 248 ms 56776 KB Output is correct
47 Correct 247 ms 56136 KB Output is correct
48 Correct 0 ms 600 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 322 ms 62572 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -