답안 #435522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
435522 2021-06-23T11:56:09 Z b00n0rp 분수 공원 (IOI21_parks) C++17
30 / 100
876 ms 49996 KB
#include "parks.h"
#include<bits/stdc++.h>

using namespace std;

#define int long long

#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define vi vector<int>
#define pb push_back
#define SZ(v) (int)v.size()
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second

const int MX = 200005;

int n;
pii a[MX];
set<pair<pii,int> > st;

vector<pii> dir = {{-2,0},{2,0},{0,-2},{0,2}};

vi adj[MX];
int par[MX];

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

signed construct_roads(vector<signed> x, vector<signed> y){
	n = SZ(x);
	REP(i,n){
		a[i] = {x[i],y[i]};
		st.insert({a[i],i});
		par[i] = i;
	}
	vector<pii> edges;
	REP(i,n){
		REP(j,4){
			pii bruh = {x[i]+dir[j].F,y[i]+dir[j].S};
			auto it = st.lower_bound({bruh,0});
			if(it != st.end()){
				if((*it).F == bruh){
					adj[i].pb((*it).S);
					if(i < (*it).S) edges.pb({i,(*it).S});
				}
			}
		}
	}
    vector<signed> u0, v0, a0, b0;
	for(auto i:edges){
		int u = i.F,v = i.S;
		// cout << u << " " << v << "\n";
		if(find(u) == find(v)) continue;
		if(a[u] > a[v]) swap(u,v);
		if(x[u] != x[v]){
			continue;
		}
		else{
			par[find(u)] = find(v);
			u0.pb(u);
			v0.pb(v);
			if(x[u] == 2){
				a0.pb(x[u]-1);
				b0.pb(y[u]+1);
			}
			else if(x[u] == 6){
				a0.pb(x[u]+1);
				b0.pb(y[u]+1);
			}
			else if((x[u]+y[u])%4 == 0){
				a0.pb(x[u]-1);
				b0.pb(y[u]+1);
			}
			else{
				a0.pb(x[u]+1);
				b0.pb(y[u]+1);
			}
		}
	}
	for(auto i:edges){
		int u = i.F,v = i.S;
		// cout << u << " " << v << "\n";
		if(find(u) == find(v)) continue;
		if(a[u] > a[v]) swap(u,v);
		if(x[u] != x[v]){
			par[find(u)] = find(v);
			u0.pb(u);
			v0.pb(v);
			if((x[u]+y[u])%4 == 0){
				a0.pb(x[u]+1);
				b0.pb(y[u]+1);
			}
			else{
				a0.pb(x[u]+1);
				b0.pb(y[u]-1);
			}
		}
		else{
			continue;
		}
	}
	REP(i,n){
		if(find(i) != find(1)) return 0;
	}
    build(u0, v0, a0, b0);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 5 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 9 ms 4916 KB Output is correct
8 Correct 8 ms 4940 KB Output is correct
9 Correct 258 ms 24840 KB Output is correct
10 Correct 17 ms 7112 KB Output is correct
11 Correct 99 ms 16300 KB Output is correct
12 Correct 24 ms 8108 KB Output is correct
13 Correct 49 ms 13236 KB Output is correct
14 Correct 4 ms 5164 KB Output is correct
15 Correct 6 ms 5324 KB Output is correct
16 Correct 242 ms 24936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 5 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 9 ms 4916 KB Output is correct
8 Correct 8 ms 4940 KB Output is correct
9 Correct 258 ms 24840 KB Output is correct
10 Correct 17 ms 7112 KB Output is correct
11 Correct 99 ms 16300 KB Output is correct
12 Correct 24 ms 8108 KB Output is correct
13 Correct 49 ms 13236 KB Output is correct
14 Correct 4 ms 5164 KB Output is correct
15 Correct 6 ms 5324 KB Output is correct
16 Correct 242 ms 24936 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 4 ms 4888 KB Output is correct
19 Correct 6 ms 4980 KB Output is correct
20 Correct 4 ms 4940 KB Output is correct
21 Correct 6 ms 4940 KB Output is correct
22 Correct 6 ms 4940 KB Output is correct
23 Correct 765 ms 49488 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 5 ms 5196 KB Output is correct
26 Correct 7 ms 5580 KB Output is correct
27 Correct 8 ms 5708 KB Output is correct
28 Correct 269 ms 23048 KB Output is correct
29 Correct 385 ms 31332 KB Output is correct
30 Correct 677 ms 41180 KB Output is correct
31 Correct 783 ms 49552 KB Output is correct
32 Correct 5 ms 4940 KB Output is correct
33 Correct 4 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 5 ms 4940 KB Output is correct
37 Correct 5 ms 4956 KB Output is correct
38 Correct 4 ms 4940 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 4 ms 4940 KB Output is correct
41 Correct 4 ms 4940 KB Output is correct
42 Correct 4 ms 4940 KB Output is correct
43 Correct 7 ms 5324 KB Output is correct
44 Correct 8 ms 5452 KB Output is correct
45 Correct 351 ms 25216 KB Output is correct
46 Correct 532 ms 35164 KB Output is correct
47 Correct 617 ms 35192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 5 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 9 ms 4916 KB Output is correct
8 Correct 8 ms 4940 KB Output is correct
9 Correct 258 ms 24840 KB Output is correct
10 Correct 17 ms 7112 KB Output is correct
11 Correct 99 ms 16300 KB Output is correct
12 Correct 24 ms 8108 KB Output is correct
13 Correct 49 ms 13236 KB Output is correct
14 Correct 4 ms 5164 KB Output is correct
15 Correct 6 ms 5324 KB Output is correct
16 Correct 242 ms 24936 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 4 ms 4888 KB Output is correct
19 Correct 6 ms 4980 KB Output is correct
20 Correct 4 ms 4940 KB Output is correct
21 Correct 6 ms 4940 KB Output is correct
22 Correct 6 ms 4940 KB Output is correct
23 Correct 765 ms 49488 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 5 ms 5196 KB Output is correct
26 Correct 7 ms 5580 KB Output is correct
27 Correct 8 ms 5708 KB Output is correct
28 Correct 269 ms 23048 KB Output is correct
29 Correct 385 ms 31332 KB Output is correct
30 Correct 677 ms 41180 KB Output is correct
31 Correct 783 ms 49552 KB Output is correct
32 Correct 5 ms 4940 KB Output is correct
33 Correct 4 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 5 ms 4940 KB Output is correct
37 Correct 5 ms 4956 KB Output is correct
38 Correct 4 ms 4940 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 4 ms 4940 KB Output is correct
41 Correct 4 ms 4940 KB Output is correct
42 Correct 4 ms 4940 KB Output is correct
43 Correct 7 ms 5324 KB Output is correct
44 Correct 8 ms 5452 KB Output is correct
45 Correct 351 ms 25216 KB Output is correct
46 Correct 532 ms 35164 KB Output is correct
47 Correct 617 ms 35192 KB Output is correct
48 Correct 4 ms 4940 KB Output is correct
49 Correct 4 ms 4940 KB Output is correct
50 Correct 4 ms 4940 KB Output is correct
51 Correct 4 ms 4940 KB Output is correct
52 Correct 4 ms 4940 KB Output is correct
53 Correct 10 ms 4940 KB Output is correct
54 Correct 7 ms 4940 KB Output is correct
55 Correct 876 ms 49976 KB Output is correct
56 Correct 4 ms 4940 KB Output is correct
57 Correct 7 ms 5324 KB Output is correct
58 Correct 14 ms 6348 KB Output is correct
59 Correct 18 ms 6992 KB Output is correct
60 Correct 315 ms 27516 KB Output is correct
61 Correct 502 ms 36404 KB Output is correct
62 Correct 692 ms 42680 KB Output is correct
63 Correct 814 ms 49996 KB Output is correct
64 Correct 3 ms 4940 KB Output is correct
65 Correct 4 ms 4940 KB Output is correct
66 Correct 4 ms 4940 KB Output is correct
67 Correct 647 ms 44832 KB Output is correct
68 Correct 641 ms 44792 KB Output is correct
69 Correct 616 ms 44684 KB Output is correct
70 Correct 11 ms 5708 KB Output is correct
71 Correct 17 ms 6368 KB Output is correct
72 Correct 328 ms 25336 KB Output is correct
73 Correct 551 ms 36112 KB Output is correct
74 Correct 767 ms 45496 KB Output is correct
75 Correct 806 ms 46648 KB Output is correct
76 Correct 632 ms 44848 KB Output is correct
77 Correct 10 ms 5836 KB Output is correct
78 Correct 20 ms 6684 KB Output is correct
79 Correct 305 ms 25556 KB Output is correct
80 Correct 516 ms 36596 KB Output is correct
81 Correct 799 ms 46136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 5 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 9 ms 4916 KB Output is correct
8 Correct 8 ms 4940 KB Output is correct
9 Correct 258 ms 24840 KB Output is correct
10 Correct 17 ms 7112 KB Output is correct
11 Correct 99 ms 16300 KB Output is correct
12 Correct 24 ms 8108 KB Output is correct
13 Correct 49 ms 13236 KB Output is correct
14 Correct 4 ms 5164 KB Output is correct
15 Correct 6 ms 5324 KB Output is correct
16 Correct 242 ms 24936 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 4 ms 4940 KB Output is correct
20 Correct 818 ms 45340 KB Output is correct
21 Incorrect 777 ms 45068 KB Tree @(7, 11) appears more than once: for edges on positions 7954 and 107977
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 5 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 9 ms 4916 KB Output is correct
8 Correct 8 ms 4940 KB Output is correct
9 Correct 258 ms 24840 KB Output is correct
10 Correct 17 ms 7112 KB Output is correct
11 Correct 99 ms 16300 KB Output is correct
12 Correct 24 ms 8108 KB Output is correct
13 Correct 49 ms 13236 KB Output is correct
14 Correct 4 ms 5164 KB Output is correct
15 Correct 6 ms 5324 KB Output is correct
16 Correct 242 ms 24936 KB Output is correct
17 Correct 671 ms 44856 KB Output is correct
18 Correct 793 ms 44984 KB Output is correct
19 Incorrect 846 ms 45096 KB Tree @(7, 49999) appears more than once: for edges on positions 30768 and 130680
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 5 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 9 ms 4916 KB Output is correct
8 Correct 8 ms 4940 KB Output is correct
9 Correct 258 ms 24840 KB Output is correct
10 Correct 17 ms 7112 KB Output is correct
11 Correct 99 ms 16300 KB Output is correct
12 Correct 24 ms 8108 KB Output is correct
13 Correct 49 ms 13236 KB Output is correct
14 Correct 4 ms 5164 KB Output is correct
15 Correct 6 ms 5324 KB Output is correct
16 Correct 242 ms 24936 KB Output is correct
17 Correct 3 ms 4940 KB Output is correct
18 Correct 4 ms 4888 KB Output is correct
19 Correct 6 ms 4980 KB Output is correct
20 Correct 4 ms 4940 KB Output is correct
21 Correct 6 ms 4940 KB Output is correct
22 Correct 6 ms 4940 KB Output is correct
23 Correct 765 ms 49488 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 5 ms 5196 KB Output is correct
26 Correct 7 ms 5580 KB Output is correct
27 Correct 8 ms 5708 KB Output is correct
28 Correct 269 ms 23048 KB Output is correct
29 Correct 385 ms 31332 KB Output is correct
30 Correct 677 ms 41180 KB Output is correct
31 Correct 783 ms 49552 KB Output is correct
32 Correct 5 ms 4940 KB Output is correct
33 Correct 4 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 5 ms 4940 KB Output is correct
37 Correct 5 ms 4956 KB Output is correct
38 Correct 4 ms 4940 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 4 ms 4940 KB Output is correct
41 Correct 4 ms 4940 KB Output is correct
42 Correct 4 ms 4940 KB Output is correct
43 Correct 7 ms 5324 KB Output is correct
44 Correct 8 ms 5452 KB Output is correct
45 Correct 351 ms 25216 KB Output is correct
46 Correct 532 ms 35164 KB Output is correct
47 Correct 617 ms 35192 KB Output is correct
48 Correct 4 ms 4940 KB Output is correct
49 Correct 4 ms 4940 KB Output is correct
50 Correct 4 ms 4940 KB Output is correct
51 Correct 4 ms 4940 KB Output is correct
52 Correct 4 ms 4940 KB Output is correct
53 Correct 10 ms 4940 KB Output is correct
54 Correct 7 ms 4940 KB Output is correct
55 Correct 876 ms 49976 KB Output is correct
56 Correct 4 ms 4940 KB Output is correct
57 Correct 7 ms 5324 KB Output is correct
58 Correct 14 ms 6348 KB Output is correct
59 Correct 18 ms 6992 KB Output is correct
60 Correct 315 ms 27516 KB Output is correct
61 Correct 502 ms 36404 KB Output is correct
62 Correct 692 ms 42680 KB Output is correct
63 Correct 814 ms 49996 KB Output is correct
64 Correct 3 ms 4940 KB Output is correct
65 Correct 4 ms 4940 KB Output is correct
66 Correct 4 ms 4940 KB Output is correct
67 Correct 647 ms 44832 KB Output is correct
68 Correct 641 ms 44792 KB Output is correct
69 Correct 616 ms 44684 KB Output is correct
70 Correct 11 ms 5708 KB Output is correct
71 Correct 17 ms 6368 KB Output is correct
72 Correct 328 ms 25336 KB Output is correct
73 Correct 551 ms 36112 KB Output is correct
74 Correct 767 ms 45496 KB Output is correct
75 Correct 806 ms 46648 KB Output is correct
76 Correct 632 ms 44848 KB Output is correct
77 Correct 10 ms 5836 KB Output is correct
78 Correct 20 ms 6684 KB Output is correct
79 Correct 305 ms 25556 KB Output is correct
80 Correct 516 ms 36596 KB Output is correct
81 Correct 799 ms 46136 KB Output is correct
82 Correct 3 ms 4940 KB Output is correct
83 Correct 4 ms 4940 KB Output is correct
84 Correct 4 ms 4940 KB Output is correct
85 Correct 818 ms 45340 KB Output is correct
86 Incorrect 777 ms 45068 KB Tree @(7, 11) appears more than once: for edges on positions 7954 and 107977
87 Halted 0 ms 0 KB -