답안 #104244

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104244 2019-04-04T11:45:22 Z puyu_liao 원 고르기 (APIO18_circle_selection) C++14
7 / 100
2153 ms 41324 KB
#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 300005
#define int int64_t

inline int hh(int x,int y){
	return x*2000000007 + y;
}

int n;
bitset<N> gg;
unordered_map<int,vector<int> > mp; 
int nb,ans[N],xx[N],yy[N],rr[N];
vector<int> ord;

void build(){
	mp.clear();
	for(int i=0;i<n;i++) if(!gg[i]){
		int t = hh(xx[i]/nb,yy[i]/nb);
		mp[t].push_back(i);
	}
}

bool cov(int i,int j){
	return (xx[i]-xx[j])*(xx[i]-xx[j]) + (yy[i]-yy[j])*(yy[i]-yy[j]) <= (rr[i]+rr[j])*(rr[i]+rr[j]);
}

void qur(int x){
	int bx = xx[x]/nb, by = yy[x]/nb;
	ans[x] = x; gg[x] = 1;
	for(int i=bx-2;i<=bx+2;i++) for(int j=by-2;j<=by+2;j++){
		auto it = mp.find(hh(i,j));
		if(it != mp.end()) for(int k : it->second) if(!gg[k] && cov(k,x)){
			ans[k] = x;
			gg[k] = 1;
		}
	}
}

int32_t main()
{
	IOS;
	cin >> n;
	int mnx,mny; mnx = mny = 1ll<<60;
	ord.resize(n);
	for(int i=0;i<n;i++) {
		cin >> xx[i] >> yy[i] >> rr[i];
		mnx = min(mnx,xx[i]);
		mny = min(mny,yy[i]);
		ord[i] = i;
	}
	for(int i=0;i<n;i++){
		xx[i] = xx[i] - mnx + 1;
		yy[i] = yy[i] - mny + 1;
	}
	sort(ord.begin(),ord.end(),[](int x,int y){return rr[x] > rr[y];});
	nb = 1 << __lg(2*rr[ord[0]]-1); 
	build();
	for(int i : ord) if(!gg[i]){
		while(rr[i] <= (nb>>1)) nb>>=1,build();
		qur(i);
	}
	for(int i=0;i<n;i++) cout << ans[i]+1 << ' ';
   return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 6 ms 896 KB Output is correct
20 Correct 8 ms 896 KB Output is correct
21 Correct 8 ms 768 KB Output is correct
22 Correct 13 ms 1152 KB Output is correct
23 Correct 12 ms 1152 KB Output is correct
24 Correct 15 ms 1152 KB Output is correct
25 Correct 13 ms 1152 KB Output is correct
26 Correct 13 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 213 ms 15028 KB Output is correct
2 Correct 217 ms 14568 KB Output is correct
3 Correct 191 ms 22360 KB Output is correct
4 Correct 196 ms 20908 KB Output is correct
5 Incorrect 305 ms 20860 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 620 ms 13576 KB Output is correct
3 Correct 2153 ms 41224 KB Output is correct
4 Correct 1889 ms 41156 KB Output is correct
5 Incorrect 1846 ms 37152 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1869 ms 41324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 6 ms 896 KB Output is correct
20 Correct 8 ms 896 KB Output is correct
21 Correct 8 ms 768 KB Output is correct
22 Correct 13 ms 1152 KB Output is correct
23 Correct 12 ms 1152 KB Output is correct
24 Correct 15 ms 1152 KB Output is correct
25 Correct 13 ms 1152 KB Output is correct
26 Correct 13 ms 1152 KB Output is correct
27 Correct 8 ms 1280 KB Output is correct
28 Correct 8 ms 1404 KB Output is correct
29 Correct 9 ms 1280 KB Output is correct
30 Correct 25 ms 1916 KB Output is correct
31 Correct 28 ms 2036 KB Output is correct
32 Correct 25 ms 1920 KB Output is correct
33 Correct 77 ms 8904 KB Output is correct
34 Correct 83 ms 9000 KB Output is correct
35 Correct 72 ms 8172 KB Output is correct
36 Correct 518 ms 16056 KB Output is correct
37 Correct 520 ms 16264 KB Output is correct
38 Correct 575 ms 16316 KB Output is correct
39 Incorrect 550 ms 13752 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 6 ms 896 KB Output is correct
20 Correct 8 ms 896 KB Output is correct
21 Correct 8 ms 768 KB Output is correct
22 Correct 13 ms 1152 KB Output is correct
23 Correct 12 ms 1152 KB Output is correct
24 Correct 15 ms 1152 KB Output is correct
25 Correct 13 ms 1152 KB Output is correct
26 Correct 13 ms 1152 KB Output is correct
27 Correct 213 ms 15028 KB Output is correct
28 Correct 217 ms 14568 KB Output is correct
29 Correct 191 ms 22360 KB Output is correct
30 Correct 196 ms 20908 KB Output is correct
31 Incorrect 305 ms 20860 KB Output isn't correct
32 Halted 0 ms 0 KB -