Submission #104243

# Submission time Handle Problem Language Result Execution time Memory
104243 2019-04-04T11:38:10 Z puyu_liao Circle selection (APIO18_circle_selection) C++14
0 / 100
1950 ms 49292 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(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;
}

# Verdict Execution time Memory 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 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 2 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 225 ms 20644 KB Output is correct
2 Incorrect 206 ms 20520 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 537 ms 16416 KB Output is correct
3 Correct 1950 ms 49152 KB Output is correct
4 Correct 1822 ms 49292 KB Output is correct
5 Incorrect 1900 ms 45072 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1810 ms 46820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 2 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Incorrect 2 ms 384 KB Output isn't correct
11 Halted 0 ms 0 KB -