답안 #75660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75660 2018-09-10T16:54:34 Z tmwilliamlin168 원 고르기 (APIO18_circle_selection) C++14
87 / 100
3000 ms 253684 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

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

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({y[p2[i]]>>k, 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, 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) {
				auto mf=mp.find(b);
				if(mf==mp.end())
					continue;
				vector<array<int, 2>> &v=mf->second;
				for(int j=lower_bound(v.begin(), v.end(), array<int, 2>{(y[p[i]]>>k)-2, 0})-v.begin(); j<v.size()&&v[j][0]<=(y[p[i]]>>k)+2; ++j) {
					ll dx=x[p[i]]-x[v[j][1]], dy=y[p[i]]-y[v[j][1]], rs=r[p[i]]+r[v[j][1]];
					if(dx*dx+dy*dy<=rs*rs&&a[v[j][1]]==-1)
						a[v[j][1]]=p[i];
				}
			}
		}
	}
	for(int i=0; i<n; ++i)
		cout << a[i]+1 << " ";
}

Compilation message

circle_selection.cpp: In function 'void rs(int)':
circle_selection.cpp:15:39: warning: narrowing conversion of '(y[p2[i]] >> k)' from 'long long int' to 'int' inside { } [-Wnarrowing]
    mp[x[p2[i]]>>k].push_back({y[p2[i]]>>k, p2[i]});
                               ~~~~~~~~^~~
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:44:73: warning: narrowing conversion of '((y[p[i]] >> k) - 2)' from 'long long int' to 'int' inside { } [-Wnarrowing]
     for(int j=lower_bound(v.begin(), v.end(), array<int, 2>{(y[p[i]]>>k)-2, 0})-v.begin(); j<v.size()&&v[j][0]<=(y[p[i]]>>k)+2; ++j) {
                                                             ~~~~~~~~~~~~^~
circle_selection.cpp:44:93: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=lower_bound(v.begin(), v.end(), array<int, 2>{(y[p[i]]>>k)-2, 0})-v.begin(); j<v.size()&&v[j][0]<=(y[p[i]]>>k)+2; ++j) {
                                                                                            ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 520 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
9 Correct 2 ms 532 KB Output is correct
10 Correct 2 ms 532 KB Output is correct
11 Correct 2 ms 532 KB Output is correct
12 Correct 2 ms 532 KB Output is correct
13 Correct 3 ms 532 KB Output is correct
14 Correct 2 ms 564 KB Output is correct
15 Correct 3 ms 564 KB Output is correct
16 Correct 3 ms 664 KB Output is correct
17 Correct 3 ms 664 KB Output is correct
18 Correct 3 ms 664 KB Output is correct
19 Correct 6 ms 836 KB Output is correct
20 Correct 6 ms 964 KB Output is correct
21 Correct 6 ms 964 KB Output is correct
22 Correct 11 ms 1020 KB Output is correct
23 Correct 10 ms 1020 KB Output is correct
24 Correct 12 ms 1280 KB Output is correct
25 Correct 18 ms 1296 KB Output is correct
26 Correct 12 ms 1296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 238 ms 15280 KB Output is correct
2 Correct 244 ms 15912 KB Output is correct
3 Correct 260 ms 15912 KB Output is correct
4 Correct 216 ms 15912 KB Output is correct
5 Correct 448 ms 17888 KB Output is correct
6 Correct 823 ms 25484 KB Output is correct
7 Correct 453 ms 25484 KB Output is correct
8 Correct 531 ms 25484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 25484 KB Output is correct
2 Correct 233 ms 25484 KB Output is correct
3 Correct 953 ms 25484 KB Output is correct
4 Correct 980 ms 25484 KB Output is correct
5 Correct 705 ms 25484 KB Output is correct
6 Correct 321 ms 25484 KB Output is correct
7 Correct 154 ms 25484 KB Output is correct
8 Correct 35 ms 25484 KB Output is correct
9 Correct 878 ms 25484 KB Output is correct
10 Correct 683 ms 25484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 971 ms 25484 KB Output is correct
2 Correct 2870 ms 40268 KB Output is correct
3 Correct 419 ms 40268 KB Output is correct
4 Correct 1870 ms 53992 KB Output is correct
5 Correct 2257 ms 62904 KB Output is correct
6 Correct 448 ms 62904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 520 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
9 Correct 2 ms 532 KB Output is correct
10 Correct 2 ms 532 KB Output is correct
11 Correct 2 ms 532 KB Output is correct
12 Correct 2 ms 532 KB Output is correct
13 Correct 3 ms 532 KB Output is correct
14 Correct 2 ms 564 KB Output is correct
15 Correct 3 ms 564 KB Output is correct
16 Correct 3 ms 664 KB Output is correct
17 Correct 3 ms 664 KB Output is correct
18 Correct 3 ms 664 KB Output is correct
19 Correct 6 ms 836 KB Output is correct
20 Correct 6 ms 964 KB Output is correct
21 Correct 6 ms 964 KB Output is correct
22 Correct 11 ms 1020 KB Output is correct
23 Correct 10 ms 1020 KB Output is correct
24 Correct 12 ms 1280 KB Output is correct
25 Correct 18 ms 1296 KB Output is correct
26 Correct 12 ms 1296 KB Output is correct
27 Correct 11 ms 62904 KB Output is correct
28 Correct 10 ms 62904 KB Output is correct
29 Correct 9 ms 62904 KB Output is correct
30 Correct 21 ms 62904 KB Output is correct
31 Correct 23 ms 62904 KB Output is correct
32 Correct 23 ms 62904 KB Output is correct
33 Correct 88 ms 62904 KB Output is correct
34 Correct 90 ms 62904 KB Output is correct
35 Correct 102 ms 62904 KB Output is correct
36 Correct 331 ms 62904 KB Output is correct
37 Correct 294 ms 62904 KB Output is correct
38 Correct 269 ms 62904 KB Output is correct
39 Correct 299 ms 62904 KB Output is correct
40 Correct 297 ms 62904 KB Output is correct
41 Correct 311 ms 62904 KB Output is correct
42 Correct 193 ms 62904 KB Output is correct
43 Correct 345 ms 62904 KB Output is correct
44 Correct 335 ms 62904 KB Output is correct
45 Correct 318 ms 62904 KB Output is correct
46 Correct 341 ms 62904 KB Output is correct
47 Correct 334 ms 62904 KB Output is correct
48 Correct 354 ms 62904 KB Output is correct
49 Correct 317 ms 62904 KB Output is correct
50 Correct 364 ms 62904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 432 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 520 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
9 Correct 2 ms 532 KB Output is correct
10 Correct 2 ms 532 KB Output is correct
11 Correct 2 ms 532 KB Output is correct
12 Correct 2 ms 532 KB Output is correct
13 Correct 3 ms 532 KB Output is correct
14 Correct 2 ms 564 KB Output is correct
15 Correct 3 ms 564 KB Output is correct
16 Correct 3 ms 664 KB Output is correct
17 Correct 3 ms 664 KB Output is correct
18 Correct 3 ms 664 KB Output is correct
19 Correct 6 ms 836 KB Output is correct
20 Correct 6 ms 964 KB Output is correct
21 Correct 6 ms 964 KB Output is correct
22 Correct 11 ms 1020 KB Output is correct
23 Correct 10 ms 1020 KB Output is correct
24 Correct 12 ms 1280 KB Output is correct
25 Correct 18 ms 1296 KB Output is correct
26 Correct 12 ms 1296 KB Output is correct
27 Correct 238 ms 15280 KB Output is correct
28 Correct 244 ms 15912 KB Output is correct
29 Correct 260 ms 15912 KB Output is correct
30 Correct 216 ms 15912 KB Output is correct
31 Correct 448 ms 17888 KB Output is correct
32 Correct 823 ms 25484 KB Output is correct
33 Correct 453 ms 25484 KB Output is correct
34 Correct 531 ms 25484 KB Output is correct
35 Correct 2 ms 25484 KB Output is correct
36 Correct 233 ms 25484 KB Output is correct
37 Correct 953 ms 25484 KB Output is correct
38 Correct 980 ms 25484 KB Output is correct
39 Correct 705 ms 25484 KB Output is correct
40 Correct 321 ms 25484 KB Output is correct
41 Correct 154 ms 25484 KB Output is correct
42 Correct 35 ms 25484 KB Output is correct
43 Correct 878 ms 25484 KB Output is correct
44 Correct 683 ms 25484 KB Output is correct
45 Correct 971 ms 25484 KB Output is correct
46 Correct 2870 ms 40268 KB Output is correct
47 Correct 419 ms 40268 KB Output is correct
48 Correct 1870 ms 53992 KB Output is correct
49 Correct 2257 ms 62904 KB Output is correct
50 Correct 448 ms 62904 KB Output is correct
51 Correct 11 ms 62904 KB Output is correct
52 Correct 10 ms 62904 KB Output is correct
53 Correct 9 ms 62904 KB Output is correct
54 Correct 21 ms 62904 KB Output is correct
55 Correct 23 ms 62904 KB Output is correct
56 Correct 23 ms 62904 KB Output is correct
57 Correct 88 ms 62904 KB Output is correct
58 Correct 90 ms 62904 KB Output is correct
59 Correct 102 ms 62904 KB Output is correct
60 Correct 331 ms 62904 KB Output is correct
61 Correct 294 ms 62904 KB Output is correct
62 Correct 269 ms 62904 KB Output is correct
63 Correct 299 ms 62904 KB Output is correct
64 Correct 297 ms 62904 KB Output is correct
65 Correct 311 ms 62904 KB Output is correct
66 Correct 193 ms 62904 KB Output is correct
67 Correct 345 ms 62904 KB Output is correct
68 Correct 335 ms 62904 KB Output is correct
69 Correct 318 ms 62904 KB Output is correct
70 Correct 341 ms 62904 KB Output is correct
71 Correct 334 ms 62904 KB Output is correct
72 Correct 354 ms 62904 KB Output is correct
73 Correct 317 ms 62904 KB Output is correct
74 Correct 364 ms 62904 KB Output is correct
75 Correct 338 ms 62904 KB Output is correct
76 Correct 371 ms 69284 KB Output is correct
77 Correct 317 ms 76756 KB Output is correct
78 Correct 293 ms 83548 KB Output is correct
79 Correct 393 ms 93796 KB Output is correct
80 Correct 294 ms 101304 KB Output is correct
81 Correct 1002 ms 113520 KB Output is correct
82 Correct 1099 ms 122552 KB Output is correct
83 Correct 1138 ms 130444 KB Output is correct
84 Correct 884 ms 137004 KB Output is correct
85 Correct 985 ms 146128 KB Output is correct
86 Correct 1076 ms 154980 KB Output is correct
87 Correct 830 ms 160136 KB Output is correct
88 Correct 1198 ms 162812 KB Output is correct
89 Correct 1179 ms 166116 KB Output is correct
90 Correct 1152 ms 169468 KB Output is correct
91 Correct 1151 ms 173024 KB Output is correct
92 Correct 1166 ms 176164 KB Output is correct
93 Correct 2695 ms 205712 KB Output is correct
94 Correct 853 ms 205712 KB Output is correct
95 Correct 2858 ms 220168 KB Output is correct
96 Correct 2225 ms 225884 KB Output is correct
97 Correct 971 ms 225884 KB Output is correct
98 Correct 1042 ms 225884 KB Output is correct
99 Correct 2755 ms 248644 KB Output is correct
100 Execution timed out 3043 ms 253684 KB Time limit exceeded
101 Halted 0 ms 0 KB -