Submission #75665

# Submission time Handle Problem Language Result Execution time Memory
75665 2018-09-10T17:17:23 Z tmwilliamlin168 Circle selection (APIO18_circle_selection) C++14
87 / 100
3000 ms 40156 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

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

struct cmp1 {
	__attribute__((always_inline)) bool operator()(const int &a, const int &b) {
		return y[a]>>k<b;
	}
};

void rs(int k) {
	mp.clear();
	for(int i=0; i<n; ++i)
		if(a[p2[i]]==-1)
			mp[x[p2[i]]>>k].push_back(p2[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];
		p[i]=p2[i]=i;
	}
	sort(p, p+n, [&](const int &a, const int &b) {
		return r[a]==r[b]?a<b:r[a]>r[b];
	});
	sort(p2, p2+n, [&](const int &a, const int &b) {
		return y[a]<y[b];
	});
	memset(a, -1, 4*n);
	for(int i=-1; 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) {
				auto mf=mp.find(b);
				if(mf==mp.end())
					continue;
				vector<int> &v=mf->second;
				for(int j=lower_bound(v.begin(), v.end(), (y[p[i]]>>k)-2, cmp1())-v.begin(); j<v.size()&&y[v[j]]>>k<=(y[p[i]]>>k)+2; ++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]]==-1)
						a[v[j]]=p[i];
				}
			}
		}
	}
	for(int i=0; i<n; ++i)
		cout << a[i]+1 << " ";
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:50:83: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=lower_bound(v.begin(), v.end(), (y[p[i]]>>k)-2, cmp1())-v.begin(); j<v.size()&&y[v[j]]>>k<=(y[p[i]]>>k)+2; ++j) {
                                                                                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 3 ms 708 KB Output is correct
17 Correct 3 ms 720 KB Output is correct
18 Correct 3 ms 720 KB Output is correct
19 Correct 6 ms 880 KB Output is correct
20 Correct 5 ms 880 KB Output is correct
21 Correct 6 ms 940 KB Output is correct
22 Correct 12 ms 1036 KB Output is correct
23 Correct 10 ms 1036 KB Output is correct
24 Correct 12 ms 1252 KB Output is correct
25 Correct 15 ms 1308 KB Output is correct
26 Correct 13 ms 1324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 235 ms 13344 KB Output is correct
2 Correct 256 ms 13820 KB Output is correct
3 Correct 277 ms 13820 KB Output is correct
4 Correct 226 ms 13820 KB Output is correct
5 Correct 393 ms 16172 KB Output is correct
6 Correct 743 ms 24308 KB Output is correct
7 Correct 402 ms 24308 KB Output is correct
8 Correct 463 ms 24308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 24308 KB Output is correct
2 Correct 244 ms 24308 KB Output is correct
3 Correct 880 ms 24308 KB Output is correct
4 Correct 886 ms 24308 KB Output is correct
5 Correct 723 ms 24308 KB Output is correct
6 Correct 313 ms 24308 KB Output is correct
7 Correct 160 ms 24308 KB Output is correct
8 Correct 36 ms 24308 KB Output is correct
9 Correct 845 ms 24308 KB Output is correct
10 Correct 659 ms 24308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 898 ms 24308 KB Output is correct
2 Correct 2507 ms 40024 KB Output is correct
3 Correct 389 ms 40024 KB Output is correct
4 Correct 1547 ms 40024 KB Output is correct
5 Correct 1860 ms 40024 KB Output is correct
6 Correct 379 ms 40024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 3 ms 708 KB Output is correct
17 Correct 3 ms 720 KB Output is correct
18 Correct 3 ms 720 KB Output is correct
19 Correct 6 ms 880 KB Output is correct
20 Correct 5 ms 880 KB Output is correct
21 Correct 6 ms 940 KB Output is correct
22 Correct 12 ms 1036 KB Output is correct
23 Correct 10 ms 1036 KB Output is correct
24 Correct 12 ms 1252 KB Output is correct
25 Correct 15 ms 1308 KB Output is correct
26 Correct 13 ms 1324 KB Output is correct
27 Correct 10 ms 40024 KB Output is correct
28 Correct 10 ms 40024 KB Output is correct
29 Correct 11 ms 40024 KB Output is correct
30 Correct 19 ms 40024 KB Output is correct
31 Correct 22 ms 40024 KB Output is correct
32 Correct 23 ms 40024 KB Output is correct
33 Correct 90 ms 40024 KB Output is correct
34 Correct 92 ms 40024 KB Output is correct
35 Correct 100 ms 40024 KB Output is correct
36 Correct 244 ms 40024 KB Output is correct
37 Correct 257 ms 40024 KB Output is correct
38 Correct 229 ms 40024 KB Output is correct
39 Correct 291 ms 40024 KB Output is correct
40 Correct 316 ms 40024 KB Output is correct
41 Correct 303 ms 40024 KB Output is correct
42 Correct 183 ms 40024 KB Output is correct
43 Correct 319 ms 40024 KB Output is correct
44 Correct 343 ms 40024 KB Output is correct
45 Correct 373 ms 40024 KB Output is correct
46 Correct 375 ms 40024 KB Output is correct
47 Correct 381 ms 40024 KB Output is correct
48 Correct 332 ms 40024 KB Output is correct
49 Correct 378 ms 40024 KB Output is correct
50 Correct 324 ms 40024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 3 ms 708 KB Output is correct
17 Correct 3 ms 720 KB Output is correct
18 Correct 3 ms 720 KB Output is correct
19 Correct 6 ms 880 KB Output is correct
20 Correct 5 ms 880 KB Output is correct
21 Correct 6 ms 940 KB Output is correct
22 Correct 12 ms 1036 KB Output is correct
23 Correct 10 ms 1036 KB Output is correct
24 Correct 12 ms 1252 KB Output is correct
25 Correct 15 ms 1308 KB Output is correct
26 Correct 13 ms 1324 KB Output is correct
27 Correct 235 ms 13344 KB Output is correct
28 Correct 256 ms 13820 KB Output is correct
29 Correct 277 ms 13820 KB Output is correct
30 Correct 226 ms 13820 KB Output is correct
31 Correct 393 ms 16172 KB Output is correct
32 Correct 743 ms 24308 KB Output is correct
33 Correct 402 ms 24308 KB Output is correct
34 Correct 463 ms 24308 KB Output is correct
35 Correct 4 ms 24308 KB Output is correct
36 Correct 244 ms 24308 KB Output is correct
37 Correct 880 ms 24308 KB Output is correct
38 Correct 886 ms 24308 KB Output is correct
39 Correct 723 ms 24308 KB Output is correct
40 Correct 313 ms 24308 KB Output is correct
41 Correct 160 ms 24308 KB Output is correct
42 Correct 36 ms 24308 KB Output is correct
43 Correct 845 ms 24308 KB Output is correct
44 Correct 659 ms 24308 KB Output is correct
45 Correct 898 ms 24308 KB Output is correct
46 Correct 2507 ms 40024 KB Output is correct
47 Correct 389 ms 40024 KB Output is correct
48 Correct 1547 ms 40024 KB Output is correct
49 Correct 1860 ms 40024 KB Output is correct
50 Correct 379 ms 40024 KB Output is correct
51 Correct 10 ms 40024 KB Output is correct
52 Correct 10 ms 40024 KB Output is correct
53 Correct 11 ms 40024 KB Output is correct
54 Correct 19 ms 40024 KB Output is correct
55 Correct 22 ms 40024 KB Output is correct
56 Correct 23 ms 40024 KB Output is correct
57 Correct 90 ms 40024 KB Output is correct
58 Correct 92 ms 40024 KB Output is correct
59 Correct 100 ms 40024 KB Output is correct
60 Correct 244 ms 40024 KB Output is correct
61 Correct 257 ms 40024 KB Output is correct
62 Correct 229 ms 40024 KB Output is correct
63 Correct 291 ms 40024 KB Output is correct
64 Correct 316 ms 40024 KB Output is correct
65 Correct 303 ms 40024 KB Output is correct
66 Correct 183 ms 40024 KB Output is correct
67 Correct 319 ms 40024 KB Output is correct
68 Correct 343 ms 40024 KB Output is correct
69 Correct 373 ms 40024 KB Output is correct
70 Correct 375 ms 40024 KB Output is correct
71 Correct 381 ms 40024 KB Output is correct
72 Correct 332 ms 40024 KB Output is correct
73 Correct 378 ms 40024 KB Output is correct
74 Correct 324 ms 40024 KB Output is correct
75 Correct 305 ms 40024 KB Output is correct
76 Correct 315 ms 40024 KB Output is correct
77 Correct 310 ms 40024 KB Output is correct
78 Correct 299 ms 40024 KB Output is correct
79 Correct 379 ms 40024 KB Output is correct
80 Correct 349 ms 40024 KB Output is correct
81 Correct 846 ms 40024 KB Output is correct
82 Correct 894 ms 40024 KB Output is correct
83 Correct 1092 ms 40024 KB Output is correct
84 Correct 945 ms 40024 KB Output is correct
85 Correct 890 ms 40024 KB Output is correct
86 Correct 1047 ms 40024 KB Output is correct
87 Correct 897 ms 40024 KB Output is correct
88 Correct 1046 ms 40024 KB Output is correct
89 Correct 1228 ms 40024 KB Output is correct
90 Correct 1103 ms 40024 KB Output is correct
91 Correct 1129 ms 40024 KB Output is correct
92 Correct 1073 ms 40024 KB Output is correct
93 Correct 2220 ms 40024 KB Output is correct
94 Correct 769 ms 40024 KB Output is correct
95 Correct 2327 ms 40024 KB Output is correct
96 Correct 1987 ms 40024 KB Output is correct
97 Correct 1026 ms 40024 KB Output is correct
98 Correct 980 ms 40024 KB Output is correct
99 Correct 2437 ms 40024 KB Output is correct
100 Execution timed out 3085 ms 40156 KB Time limit exceeded
101 Halted 0 ms 0 KB -