답안 #75648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75648 2018-09-10T16:22:50 Z tmwilliamlin168 원 고르기 (APIO18_circle_selection) C++14
49 / 100
3000 ms 114256 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];
		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) {
					int ns=0;
					vector<int> &v=mp[b<<32|c];
					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:40:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for(int j=0; j<v.size(); ++j) {
                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 436 KB Output is correct
3 Correct 2 ms 524 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 628 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 3 ms 736 KB Output is correct
16 Correct 3 ms 736 KB Output is correct
17 Correct 3 ms 736 KB Output is correct
18 Correct 3 ms 736 KB Output is correct
19 Correct 6 ms 864 KB Output is correct
20 Correct 8 ms 864 KB Output is correct
21 Correct 6 ms 880 KB Output is correct
22 Correct 37 ms 4656 KB Output is correct
23 Correct 22 ms 4656 KB Output is correct
24 Correct 17 ms 4656 KB Output is correct
25 Correct 41 ms 4656 KB Output is correct
26 Correct 31 ms 4656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 252 ms 14140 KB Output is correct
2 Correct 251 ms 14140 KB Output is correct
3 Correct 260 ms 14140 KB Output is correct
4 Correct 235 ms 14140 KB Output is correct
5 Correct 426 ms 14940 KB Output is correct
6 Correct 1236 ms 36824 KB Output is correct
7 Correct 458 ms 36824 KB Output is correct
8 Correct 582 ms 36824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 36824 KB Output is correct
2 Correct 827 ms 37768 KB Output is correct
3 Execution timed out 3048 ms 96104 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1065 ms 96104 KB Output is correct
2 Execution timed out 3047 ms 96104 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 436 KB Output is correct
3 Correct 2 ms 524 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 628 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 3 ms 736 KB Output is correct
16 Correct 3 ms 736 KB Output is correct
17 Correct 3 ms 736 KB Output is correct
18 Correct 3 ms 736 KB Output is correct
19 Correct 6 ms 864 KB Output is correct
20 Correct 8 ms 864 KB Output is correct
21 Correct 6 ms 880 KB Output is correct
22 Correct 37 ms 4656 KB Output is correct
23 Correct 22 ms 4656 KB Output is correct
24 Correct 17 ms 4656 KB Output is correct
25 Correct 41 ms 4656 KB Output is correct
26 Correct 31 ms 4656 KB Output is correct
27 Correct 16 ms 96104 KB Output is correct
28 Correct 10 ms 96104 KB Output is correct
29 Correct 9 ms 96104 KB Output is correct
30 Correct 39 ms 96104 KB Output is correct
31 Correct 86 ms 96104 KB Output is correct
32 Correct 35 ms 96104 KB Output is correct
33 Correct 78 ms 96104 KB Output is correct
34 Correct 86 ms 96104 KB Output is correct
35 Correct 84 ms 96104 KB Output is correct
36 Correct 1587 ms 96104 KB Output is correct
37 Correct 406 ms 96104 KB Output is correct
38 Correct 353 ms 96104 KB Output is correct
39 Correct 650 ms 96104 KB Output is correct
40 Correct 700 ms 96104 KB Output is correct
41 Correct 696 ms 96104 KB Output is correct
42 Correct 209 ms 96104 KB Output is correct
43 Correct 1114 ms 96360 KB Output is correct
44 Correct 1158 ms 98592 KB Output is correct
45 Correct 1022 ms 101220 KB Output is correct
46 Correct 1103 ms 103820 KB Output is correct
47 Correct 1139 ms 106768 KB Output is correct
48 Correct 1061 ms 109416 KB Output is correct
49 Correct 1085 ms 111676 KB Output is correct
50 Correct 1018 ms 114256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 436 KB Output is correct
3 Correct 2 ms 524 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 592 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 628 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 3 ms 736 KB Output is correct
16 Correct 3 ms 736 KB Output is correct
17 Correct 3 ms 736 KB Output is correct
18 Correct 3 ms 736 KB Output is correct
19 Correct 6 ms 864 KB Output is correct
20 Correct 8 ms 864 KB Output is correct
21 Correct 6 ms 880 KB Output is correct
22 Correct 37 ms 4656 KB Output is correct
23 Correct 22 ms 4656 KB Output is correct
24 Correct 17 ms 4656 KB Output is correct
25 Correct 41 ms 4656 KB Output is correct
26 Correct 31 ms 4656 KB Output is correct
27 Correct 252 ms 14140 KB Output is correct
28 Correct 251 ms 14140 KB Output is correct
29 Correct 260 ms 14140 KB Output is correct
30 Correct 235 ms 14140 KB Output is correct
31 Correct 426 ms 14940 KB Output is correct
32 Correct 1236 ms 36824 KB Output is correct
33 Correct 458 ms 36824 KB Output is correct
34 Correct 582 ms 36824 KB Output is correct
35 Correct 3 ms 36824 KB Output is correct
36 Correct 827 ms 37768 KB Output is correct
37 Execution timed out 3048 ms 96104 KB Time limit exceeded
38 Halted 0 ms 0 KB -