답안 #544187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544187 2022-04-01T09:47:42 Z amunduzbaev 원 고르기 (APIO18_circle_selection) C++17
7 / 100
1330 ms 39360 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array
#define int long long
const double eps = 1e-9;

struct poi{
	int x, y, r;
};

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	vector<poi> a(n);
	vector<set<ar<int, 2>>> pp;
	vector<int> used(n), tot;
	int R;
	auto get = [&](int x){ 
		if(x >= 0) return x / R;
		else {
			return (x + 1) / R - 1;
		}
	};
	
	auto rec = [&](){
		pp.clear(); tot.clear();
		for(int i=0;i<n;i++) {
			if(used[i]) continue;
			tot.push_back(get(a[i].x));
		}
		sort(tot.begin(), tot.end());
		tot.erase(unique(tot.begin(), tot.end()), tot.end());
		pp.resize(tot.size());
		for(int i=0;i<n;i++){
			if(used[i]) continue;
			auto j = lower_bound(tot.begin(), tot.end(), get(a[i].x)) - tot.begin();
			assert(j < (int)tot.size());
			pp[j].insert({a[i].y, i});
		}
	};
	
	vector<int> p(n); 
	for(int i=0;i<n;i++){
		p[i] = i;
		cin>>a[i].x>>a[i].y>>a[i].r;
	}
	sort(p.begin(), p.end(), [&](int i, int j){
		return (a[i].r > a[j].r);
	});
	
	auto sq = [&](int x) { return x * 1ll * x; };
	auto dis = [&](int i, int j) -> double{
		return sqrt(sq(a[i].x - a[j].x) + sq(a[i].y - a[j].y));
	};
	
	auto check = [&](int i, int j){
		return (a[i].r + a[j].r - dis(i, j) > -eps);
	};
	
	R = a[p[0]].r;
	rec();
	for(auto i : p){
		if(used[i]) continue;
		if(a[i].r * 2 <= R) R = a[i].r, rec();
		int l = lower_bound(tot.begin(), tot.end(), get(a[i].x) - 2) - tot.begin();
		int r = upper_bound(tot.begin(), tot.end(), get(a[i].x) + 2) - tot.begin();
		int lx = (get(a[i].y) - 2) * R;
		int rx = (get(a[i].y) + 3) * R;
		for(int j=l;j<r;j++){
			auto it = pp[j].lower_bound({lx, -1});
			vector<ar<int, 2>> er;
			while(it != pp[j].end() && (*it)[0] < rx){
				if(check((*it)[1], i)){
					er.push_back(*it);
				} it++;
			}
			
			for(auto x : er) pp[j].erase(x), used[x[1]] = i + 1;
		}
	}
	
	for(int i=0;i<n;i++) cout<<used[i]<<" ";
	cout<<"\n";
}

/*

11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 360 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 4 ms 1016 KB Output is correct
21 Correct 4 ms 980 KB Output is correct
22 Correct 7 ms 1024 KB Output is correct
23 Correct 8 ms 852 KB Output is correct
24 Correct 7 ms 1060 KB Output is correct
25 Correct 7 ms 1132 KB Output is correct
26 Correct 6 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 267 ms 39304 KB Output is correct
2 Correct 302 ms 36716 KB Output is correct
3 Correct 286 ms 36908 KB Output is correct
4 Correct 266 ms 39360 KB Output is correct
5 Incorrect 365 ms 35456 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 180 ms 11592 KB Output is correct
3 Correct 783 ms 34052 KB Output is correct
4 Correct 736 ms 36224 KB Output is correct
5 Incorrect 841 ms 32496 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 474 ms 38904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 360 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 4 ms 1016 KB Output is correct
21 Correct 4 ms 980 KB Output is correct
22 Correct 7 ms 1024 KB Output is correct
23 Correct 8 ms 852 KB Output is correct
24 Correct 7 ms 1060 KB Output is correct
25 Correct 7 ms 1132 KB Output is correct
26 Correct 6 ms 980 KB Output is correct
27 Correct 8 ms 1620 KB Output is correct
28 Correct 8 ms 1620 KB Output is correct
29 Correct 8 ms 1580 KB Output is correct
30 Correct 14 ms 1496 KB Output is correct
31 Correct 14 ms 1748 KB Output is correct
32 Correct 13 ms 1720 KB Output is correct
33 Correct 100 ms 13456 KB Output is correct
34 Correct 109 ms 13404 KB Output is correct
35 Correct 119 ms 12824 KB Output is correct
36 Correct 168 ms 13628 KB Output is correct
37 Correct 172 ms 14736 KB Output is correct
38 Correct 168 ms 12300 KB Output is correct
39 Incorrect 1330 ms 11792 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 360 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 4 ms 1004 KB Output is correct
20 Correct 4 ms 1016 KB Output is correct
21 Correct 4 ms 980 KB Output is correct
22 Correct 7 ms 1024 KB Output is correct
23 Correct 8 ms 852 KB Output is correct
24 Correct 7 ms 1060 KB Output is correct
25 Correct 7 ms 1132 KB Output is correct
26 Correct 6 ms 980 KB Output is correct
27 Correct 267 ms 39304 KB Output is correct
28 Correct 302 ms 36716 KB Output is correct
29 Correct 286 ms 36908 KB Output is correct
30 Correct 266 ms 39360 KB Output is correct
31 Incorrect 365 ms 35456 KB Output isn't correct
32 Halted 0 ms 0 KB -