Submission #75657

# Submission time Handle Problem Language Result Execution time Memory
75657 2018-09-10T16:38:21 Z tmwilliamlin168 Circle selection (APIO18_circle_selection) C++14
64 / 100
3000 ms 37176 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxN=3e5;
int n, p[mxN], a[mxN];
ll x[mxN], y[mxN], r[mxN];
unordered_map<ll, vector<int>> mp;

void rs(int k) {
	mp.clear();
	for(int i=0; i<n; ++i)
		if(a[i]==-1)
			mp[x[i]>>k<<32|y[i]>>k].push_back(i);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> x[i] >> y[i] >> r[i], x[i]+=6969, y[i]+=696969;
		p[i]=i;
	}
	sort(p, p+n, [&](const int &a, const int &b) {
		return r[a]==r[b]?a<b:r[a]>r[b];
	});
	memset(a, -1, 4*n);
	for(int i=-1, k=30; i+1<n; --i, --k) {
		rs(k);
		while(++i<n&&r[p[i]]>=1<<(k-1)) {
			if(a[p[i]]!=-1)
				continue;
			for(ll b=(x[p[i]]>>k)-2; b<=(x[p[i]]>>k)+2; ++b) {
				for(ll c=(y[p[i]]>>k)-2; c<=(y[p[i]]>>k)+2; ++c) {
					auto mf=mp.find(b<<32|c);
					if(mf==mp.end())
						continue;
					int ns=0;
					vector<int> &v=mf->second;
					for(int j=0; j<v.size(); ++j) {
						ll dx=x[p[i]]-x[v[j]], dy=y[p[i]]-y[v[j]], rs=r[p[i]]+r[v[j]];
						if(dx*dx+dy*dy<=rs*rs)
							a[v[j]]=p[i];
						else
							v[ns++]=v[j];
					}
					v.resize(ns);
				}
			}
		}
	}
	for(int i=0; i<n; ++i)
		cout << a[i]+1 << " ";
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for(int j=0; j<v.size(); ++j) {
                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 456 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 2 ms 608 KB Output is correct
13 Correct 2 ms 608 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 3 ms 608 KB Output is correct
17 Correct 3 ms 632 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 6 ms 864 KB Output is correct
20 Correct 6 ms 864 KB Output is correct
21 Correct 6 ms 880 KB Output is correct
22 Correct 21 ms 1280 KB Output is correct
23 Correct 20 ms 1280 KB Output is correct
24 Correct 15 ms 1280 KB Output is correct
25 Correct 22 ms 1320 KB Output is correct
26 Correct 20 ms 1320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 241 ms 12320 KB Output is correct
2 Correct 247 ms 12572 KB Output is correct
3 Correct 244 ms 12572 KB Output is correct
4 Correct 249 ms 12572 KB Output is correct
5 Correct 399 ms 14904 KB Output is correct
6 Correct 831 ms 23244 KB Output is correct
7 Correct 419 ms 23244 KB Output is correct
8 Correct 487 ms 23244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 23244 KB Output is correct
2 Correct 462 ms 23244 KB Output is correct
3 Correct 1950 ms 25188 KB Output is correct
4 Correct 1876 ms 25188 KB Output is correct
5 Correct 1674 ms 25188 KB Output is correct
6 Correct 580 ms 25188 KB Output is correct
7 Correct 248 ms 25188 KB Output is correct
8 Correct 52 ms 25188 KB Output is correct
9 Correct 1783 ms 25980 KB Output is correct
10 Correct 1842 ms 25980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1014 ms 25980 KB Output is correct
2 Execution timed out 3039 ms 37176 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 456 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 2 ms 608 KB Output is correct
13 Correct 2 ms 608 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 3 ms 608 KB Output is correct
17 Correct 3 ms 632 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 6 ms 864 KB Output is correct
20 Correct 6 ms 864 KB Output is correct
21 Correct 6 ms 880 KB Output is correct
22 Correct 21 ms 1280 KB Output is correct
23 Correct 20 ms 1280 KB Output is correct
24 Correct 15 ms 1280 KB Output is correct
25 Correct 22 ms 1320 KB Output is correct
26 Correct 20 ms 1320 KB Output is correct
27 Correct 11 ms 37176 KB Output is correct
28 Correct 9 ms 37176 KB Output is correct
29 Correct 10 ms 37176 KB Output is correct
30 Correct 33 ms 37176 KB Output is correct
31 Correct 39 ms 37176 KB Output is correct
32 Correct 30 ms 37176 KB Output is correct
33 Correct 79 ms 37176 KB Output is correct
34 Correct 76 ms 37176 KB Output is correct
35 Correct 85 ms 37176 KB Output is correct
36 Correct 552 ms 37176 KB Output is correct
37 Correct 334 ms 37176 KB Output is correct
38 Correct 328 ms 37176 KB Output is correct
39 Correct 273 ms 37176 KB Output is correct
40 Correct 270 ms 37176 KB Output is correct
41 Correct 268 ms 37176 KB Output is correct
42 Correct 215 ms 37176 KB Output is correct
43 Correct 451 ms 37176 KB Output is correct
44 Correct 464 ms 37176 KB Output is correct
45 Correct 435 ms 37176 KB Output is correct
46 Correct 482 ms 37176 KB Output is correct
47 Correct 491 ms 37176 KB Output is correct
48 Correct 452 ms 37176 KB Output is correct
49 Correct 486 ms 37176 KB Output is correct
50 Correct 464 ms 37176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 456 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 2 ms 608 KB Output is correct
13 Correct 2 ms 608 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 3 ms 608 KB Output is correct
17 Correct 3 ms 632 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 6 ms 864 KB Output is correct
20 Correct 6 ms 864 KB Output is correct
21 Correct 6 ms 880 KB Output is correct
22 Correct 21 ms 1280 KB Output is correct
23 Correct 20 ms 1280 KB Output is correct
24 Correct 15 ms 1280 KB Output is correct
25 Correct 22 ms 1320 KB Output is correct
26 Correct 20 ms 1320 KB Output is correct
27 Correct 241 ms 12320 KB Output is correct
28 Correct 247 ms 12572 KB Output is correct
29 Correct 244 ms 12572 KB Output is correct
30 Correct 249 ms 12572 KB Output is correct
31 Correct 399 ms 14904 KB Output is correct
32 Correct 831 ms 23244 KB Output is correct
33 Correct 419 ms 23244 KB Output is correct
34 Correct 487 ms 23244 KB Output is correct
35 Correct 2 ms 23244 KB Output is correct
36 Correct 462 ms 23244 KB Output is correct
37 Correct 1950 ms 25188 KB Output is correct
38 Correct 1876 ms 25188 KB Output is correct
39 Correct 1674 ms 25188 KB Output is correct
40 Correct 580 ms 25188 KB Output is correct
41 Correct 248 ms 25188 KB Output is correct
42 Correct 52 ms 25188 KB Output is correct
43 Correct 1783 ms 25980 KB Output is correct
44 Correct 1842 ms 25980 KB Output is correct
45 Correct 1014 ms 25980 KB Output is correct
46 Execution timed out 3039 ms 37176 KB Time limit exceeded
47 Halted 0 ms 0 KB -