답안 #1052904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052904 2024-08-11T05:49:43 Z ReLice 분수 공원 (IOI21_parks) C++17
55 / 100
402 ms 92968 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;
}











# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 171 ms 45756 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 92 ms 25344 KB Output is correct
12 Correct 18 ms 7516 KB Output is correct
13 Correct 41 ms 14672 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 168 ms 41392 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 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 45756 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 92 ms 25344 KB Output is correct
12 Correct 18 ms 7516 KB Output is correct
13 Correct 41 ms 14672 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 168 ms 41392 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 375 ms 68296 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 816 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 120 ms 28048 KB Output is correct
29 Correct 187 ms 40300 KB Output is correct
30 Correct 272 ms 55124 KB Output is correct
31 Correct 362 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 2 ms 860 KB Output is correct
45 Correct 152 ms 38604 KB Output is correct
46 Correct 256 ms 56616 KB Output is correct
47 Correct 248 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 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 45756 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 92 ms 25344 KB Output is correct
12 Correct 18 ms 7516 KB Output is correct
13 Correct 41 ms 14672 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 168 ms 41392 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 375 ms 68296 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 816 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 120 ms 28048 KB Output is correct
29 Correct 187 ms 40300 KB Output is correct
30 Correct 272 ms 55124 KB Output is correct
31 Correct 362 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 2 ms 860 KB Output is correct
45 Correct 152 ms 38604 KB Output is correct
46 Correct 256 ms 56616 KB Output is correct
47 Correct 248 ms 56136 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 335 ms 62764 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 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 45756 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 92 ms 25344 KB Output is correct
12 Correct 18 ms 7516 KB Output is correct
13 Correct 41 ms 14672 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 168 ms 41392 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 362 ms 80480 KB Output is correct
21 Correct 333 ms 75912 KB Output is correct
22 Correct 338 ms 73456 KB Output is correct
23 Correct 283 ms 72824 KB Output is correct
24 Correct 76 ms 18324 KB Output is correct
25 Correct 71 ms 18384 KB Output is correct
26 Correct 86 ms 18264 KB Output is correct
27 Correct 270 ms 58708 KB Output is correct
28 Correct 325 ms 58704 KB Output is correct
29 Correct 395 ms 58616 KB Output is correct
30 Correct 402 ms 58884 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 19 ms 5568 KB Output is correct
33 Correct 36 ms 9280 KB Output is correct
34 Correct 370 ms 76968 KB Output is correct
35 Correct 7 ms 1880 KB Output is correct
36 Correct 27 ms 6236 KB Output is correct
37 Correct 44 ms 10568 KB Output is correct
38 Correct 117 ms 22252 KB Output is correct
39 Correct 169 ms 30412 KB Output is correct
40 Correct 244 ms 38852 KB Output is correct
41 Correct 280 ms 47152 KB Output is correct
42 Correct 342 ms 55060 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 424 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 344 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 344 KB Output is correct
54 Correct 1 ms 860 KB Output is correct
55 Correct 1 ms 860 KB Output is correct
56 Correct 169 ms 38592 KB Output is correct
57 Correct 247 ms 56656 KB Output is correct
58 Correct 250 ms 56132 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 385 ms 80468 KB Output is correct
63 Correct 358 ms 80728 KB Output is correct
64 Correct 359 ms 82696 KB Output is correct
65 Correct 3 ms 1112 KB Output is correct
66 Correct 3 ms 1372 KB Output is correct
67 Correct 172 ms 34084 KB Output is correct
68 Correct 281 ms 53808 KB Output is correct
69 Correct 356 ms 67924 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 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 45756 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 92 ms 25344 KB Output is correct
12 Correct 18 ms 7516 KB Output is correct
13 Correct 41 ms 14672 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 168 ms 41392 KB Output is correct
17 Correct 347 ms 92968 KB Output is correct
18 Correct 333 ms 84296 KB Output is correct
19 Correct 330 ms 80612 KB Output is correct
20 Correct 261 ms 59792 KB Output is correct
21 Correct 273 ms 63048 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 40 ms 10728 KB Output is correct
24 Correct 15 ms 3676 KB Output is correct
25 Correct 33 ms 8524 KB Output is correct
26 Correct 57 ms 12808 KB Output is correct
27 Correct 152 ms 31160 KB Output is correct
28 Correct 184 ms 38856 KB Output is correct
29 Correct 247 ms 47004 KB Output is correct
30 Correct 270 ms 54088 KB Output is correct
31 Correct 322 ms 62196 KB Output is correct
32 Correct 358 ms 76108 KB Output is correct
33 Correct 356 ms 86740 KB Output is correct
34 Correct 3 ms 1372 KB Output is correct
35 Correct 5 ms 2036 KB Output is correct
36 Correct 152 ms 34124 KB Output is correct
37 Correct 242 ms 51776 KB Output is correct
38 Correct 335 ms 68756 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 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 45756 KB Output is correct
10 Correct 12 ms 5212 KB Output is correct
11 Correct 92 ms 25344 KB Output is correct
12 Correct 18 ms 7516 KB Output is correct
13 Correct 41 ms 14672 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 168 ms 41392 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 375 ms 68296 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 816 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 120 ms 28048 KB Output is correct
29 Correct 187 ms 40300 KB Output is correct
30 Correct 272 ms 55124 KB Output is correct
31 Correct 362 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 2 ms 860 KB Output is correct
45 Correct 152 ms 38604 KB Output is correct
46 Correct 256 ms 56616 KB Output is correct
47 Correct 248 ms 56136 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 335 ms 62764 KB Solution announced impossible, but it is possible.
56 Halted 0 ms 0 KB -