답안 #75654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75654 2018-09-10T16:30:59 Z tmwilliamlin168 원 고르기 (APIO18_circle_selection) C++14
64 / 100
3000 ms 49676 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;
unordered_set<ll> s;

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

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) {
				if(s.find(b)==s.end())
					continue;
				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:50: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 380 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 3 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 628 KB Output is correct
12 Correct 3 ms 628 KB Output is correct
13 Correct 3 ms 628 KB Output is correct
14 Correct 2 ms 628 KB Output is correct
15 Correct 2 ms 628 KB Output is correct
16 Correct 3 ms 628 KB Output is correct
17 Correct 3 ms 628 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 5 ms 864 KB Output is correct
20 Correct 6 ms 864 KB Output is correct
21 Correct 8 ms 880 KB Output is correct
22 Correct 22 ms 1408 KB Output is correct
23 Correct 20 ms 1408 KB Output is correct
24 Correct 17 ms 1408 KB Output is correct
25 Correct 26 ms 1424 KB Output is correct
26 Correct 22 ms 1424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 257 ms 12136 KB Output is correct
2 Correct 257 ms 12516 KB Output is correct
3 Correct 265 ms 12516 KB Output is correct
4 Correct 235 ms 12516 KB Output is correct
5 Correct 501 ms 15032 KB Output is correct
6 Correct 1303 ms 29376 KB Output is correct
7 Correct 511 ms 29376 KB Output is correct
8 Correct 624 ms 29376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 29376 KB Output is correct
2 Correct 527 ms 29376 KB Output is correct
3 Correct 2419 ms 29376 KB Output is correct
4 Correct 2290 ms 29376 KB Output is correct
5 Correct 1972 ms 29376 KB Output is correct
6 Correct 700 ms 29376 KB Output is correct
7 Correct 305 ms 29376 KB Output is correct
8 Correct 58 ms 29376 KB Output is correct
9 Correct 2299 ms 29376 KB Output is correct
10 Correct 2003 ms 29376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1548 ms 29376 KB Output is correct
2 Execution timed out 3037 ms 49676 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 3 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 628 KB Output is correct
12 Correct 3 ms 628 KB Output is correct
13 Correct 3 ms 628 KB Output is correct
14 Correct 2 ms 628 KB Output is correct
15 Correct 2 ms 628 KB Output is correct
16 Correct 3 ms 628 KB Output is correct
17 Correct 3 ms 628 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 5 ms 864 KB Output is correct
20 Correct 6 ms 864 KB Output is correct
21 Correct 8 ms 880 KB Output is correct
22 Correct 22 ms 1408 KB Output is correct
23 Correct 20 ms 1408 KB Output is correct
24 Correct 17 ms 1408 KB Output is correct
25 Correct 26 ms 1424 KB Output is correct
26 Correct 22 ms 1424 KB Output is correct
27 Correct 10 ms 49676 KB Output is correct
28 Correct 10 ms 49676 KB Output is correct
29 Correct 10 ms 49676 KB Output is correct
30 Correct 38 ms 49676 KB Output is correct
31 Correct 46 ms 49676 KB Output is correct
32 Correct 39 ms 49676 KB Output is correct
33 Correct 85 ms 49676 KB Output is correct
34 Correct 80 ms 49676 KB Output is correct
35 Correct 89 ms 49676 KB Output is correct
36 Correct 715 ms 49676 KB Output is correct
37 Correct 387 ms 49676 KB Output is correct
38 Correct 367 ms 49676 KB Output is correct
39 Correct 712 ms 49676 KB Output is correct
40 Correct 722 ms 49676 KB Output is correct
41 Correct 739 ms 49676 KB Output is correct
42 Correct 243 ms 49676 KB Output is correct
43 Correct 645 ms 49676 KB Output is correct
44 Correct 651 ms 49676 KB Output is correct
45 Correct 735 ms 49676 KB Output is correct
46 Correct 764 ms 49676 KB Output is correct
47 Correct 769 ms 49676 KB Output is correct
48 Correct 811 ms 49676 KB Output is correct
49 Correct 753 ms 49676 KB Output is correct
50 Correct 633 ms 49676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 3 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 628 KB Output is correct
12 Correct 3 ms 628 KB Output is correct
13 Correct 3 ms 628 KB Output is correct
14 Correct 2 ms 628 KB Output is correct
15 Correct 2 ms 628 KB Output is correct
16 Correct 3 ms 628 KB Output is correct
17 Correct 3 ms 628 KB Output is correct
18 Correct 3 ms 628 KB Output is correct
19 Correct 5 ms 864 KB Output is correct
20 Correct 6 ms 864 KB Output is correct
21 Correct 8 ms 880 KB Output is correct
22 Correct 22 ms 1408 KB Output is correct
23 Correct 20 ms 1408 KB Output is correct
24 Correct 17 ms 1408 KB Output is correct
25 Correct 26 ms 1424 KB Output is correct
26 Correct 22 ms 1424 KB Output is correct
27 Correct 257 ms 12136 KB Output is correct
28 Correct 257 ms 12516 KB Output is correct
29 Correct 265 ms 12516 KB Output is correct
30 Correct 235 ms 12516 KB Output is correct
31 Correct 501 ms 15032 KB Output is correct
32 Correct 1303 ms 29376 KB Output is correct
33 Correct 511 ms 29376 KB Output is correct
34 Correct 624 ms 29376 KB Output is correct
35 Correct 2 ms 29376 KB Output is correct
36 Correct 527 ms 29376 KB Output is correct
37 Correct 2419 ms 29376 KB Output is correct
38 Correct 2290 ms 29376 KB Output is correct
39 Correct 1972 ms 29376 KB Output is correct
40 Correct 700 ms 29376 KB Output is correct
41 Correct 305 ms 29376 KB Output is correct
42 Correct 58 ms 29376 KB Output is correct
43 Correct 2299 ms 29376 KB Output is correct
44 Correct 2003 ms 29376 KB Output is correct
45 Correct 1548 ms 29376 KB Output is correct
46 Execution timed out 3037 ms 49676 KB Time limit exceeded
47 Halted 0 ms 0 KB -