답안 #99831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99831 2019-03-07T16:59:22 Z TadijaSebez 원 고르기 (APIO18_circle_selection) C++11
7 / 100
3000 ms 51928 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
struct circle{ ll x,y,r;int id;circle(){}circle(ll a, ll b, ll c):x(a),y(b),r(c){}};
ll sq(ll x){ return x*x;}
bool sec(circle a, circle b){ return sq(a.x-b.x)+sq(a.y-b.y)<=sq(a.r+b.r);}
bool operator < (circle a, circle b){ return a.r<b.r;}
const int N=300050;
const int mul=2e9+7;
const int inf=1e9+7;
circle a[N],b[N];
int ans[N];
unordered_map<ll,int> id;
set<pair<int,int>> all[N];
int main()
{
	int n,i;
	scanf("%i",&n);
	for(i=1;i<=n;i++) scanf("%lld %lld %lld",&a[i].x,&a[i].y,&a[i].r),a[i].id=i,b[i]=a[i];
	sort(a+1,a+1+n,[](circle a, circle b){ return a.r>b.r || a.r==b.r && a.id<b.id;});
	for(int j=30;j>=0;j--)
	{
		int po=1<<j;
		id.clear();
		int cnt=0;
		for(i=1;i<=n;i++) if(!ans[a[i].id])
		{
			pair<int,int> pa=mp(floor((double)a[i].x/po),floor((double)a[i].y/po));
			ll p=pa.first;
			if(!id[p]) id[p]=++cnt,all[cnt].clear();
			all[id[p]].insert(mp(pa.second,a[i].id));
		}
		//for(i=1;i<=cnt;i++) sort(all[i].begin(),all[i].end());
		for(i=1;i<=n;i++) if(!ans[a[i].id] && a[i].r>=(1<<j-1))
		{
			int x=floor((double)a[i].x/po);
			int y=floor((double)a[i].y/po);
			for(int l=-2;l<=2;l++)
			{
				ll p=x+l;
				if(!id.count(p)) continue;
				int idx=id[p];
				auto lb=all[idx].upper_bound(mp(y-3,inf));
				auto rb=all[idx].upper_bound(mp(y+2,inf));
				vector<pair<int,int>> er;
				for(auto r=lb;r!=rb;r++)
				{
					int c=r->second;
					if(!ans[c] && sec(b[c],a[i])) ans[c]=a[i].id;
					else er.pb(*r);
				}
				for(auto h:er) all[idx].erase(h);
			}
		}
	}
	for(i=1;i<=n;i++) printf("%i%c",ans[i],i==n?'\n':' ');
	return 0;
}

Compilation message

circle_selection.cpp: In lambda function:
circle_selection.cpp:22:68: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  sort(a+1,a+1+n,[](circle a, circle b){ return a.r>b.r || a.r==b.r && a.id<b.id;});
                                                           ~~~~~~~~~^~~~~~~~~~~~
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:36:54: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   for(i=1;i<=n;i++) if(!ans[a[i].id] && a[i].r>=(1<<j-1))
                                                     ~^~
circle_selection.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
circle_selection.cpp:21:77: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%lld %lld %lld",&a[i].x,&a[i].y,&a[i].r),a[i].id=i,b[i]=a[i];
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 14464 KB Output is correct
2 Correct 15 ms 14464 KB Output is correct
3 Correct 15 ms 14464 KB Output is correct
4 Correct 15 ms 14464 KB Output is correct
5 Correct 15 ms 14464 KB Output is correct
6 Correct 18 ms 14464 KB Output is correct
7 Correct 15 ms 14464 KB Output is correct
8 Correct 15 ms 14456 KB Output is correct
9 Correct 14 ms 14464 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 14 ms 14464 KB Output is correct
12 Correct 14 ms 14464 KB Output is correct
13 Correct 14 ms 14464 KB Output is correct
14 Correct 15 ms 14464 KB Output is correct
15 Correct 14 ms 14464 KB Output is correct
16 Correct 17 ms 14592 KB Output is correct
17 Correct 16 ms 14592 KB Output is correct
18 Correct 19 ms 14592 KB Output is correct
19 Correct 19 ms 15096 KB Output is correct
20 Correct 23 ms 15096 KB Output is correct
21 Correct 24 ms 15104 KB Output is correct
22 Correct 42 ms 15096 KB Output is correct
23 Correct 43 ms 15096 KB Output is correct
24 Correct 44 ms 15224 KB Output is correct
25 Correct 40 ms 15232 KB Output is correct
26 Correct 43 ms 15224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1157 ms 50684 KB Output is correct
2 Correct 1748 ms 50768 KB Output is correct
3 Correct 1705 ms 51928 KB Output is correct
4 Correct 726 ms 50680 KB Output is correct
5 Execution timed out 3043 ms 47352 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 14464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3024 ms 47472 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 14464 KB Output is correct
2 Correct 15 ms 14464 KB Output is correct
3 Correct 15 ms 14464 KB Output is correct
4 Correct 15 ms 14464 KB Output is correct
5 Correct 15 ms 14464 KB Output is correct
6 Correct 18 ms 14464 KB Output is correct
7 Correct 15 ms 14464 KB Output is correct
8 Correct 15 ms 14456 KB Output is correct
9 Correct 14 ms 14464 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 14 ms 14464 KB Output is correct
12 Correct 14 ms 14464 KB Output is correct
13 Correct 14 ms 14464 KB Output is correct
14 Correct 15 ms 14464 KB Output is correct
15 Correct 14 ms 14464 KB Output is correct
16 Correct 17 ms 14592 KB Output is correct
17 Correct 16 ms 14592 KB Output is correct
18 Correct 19 ms 14592 KB Output is correct
19 Correct 19 ms 15096 KB Output is correct
20 Correct 23 ms 15096 KB Output is correct
21 Correct 24 ms 15104 KB Output is correct
22 Correct 42 ms 15096 KB Output is correct
23 Correct 43 ms 15096 KB Output is correct
24 Correct 44 ms 15224 KB Output is correct
25 Correct 40 ms 15232 KB Output is correct
26 Correct 43 ms 15224 KB Output is correct
27 Correct 27 ms 15616 KB Output is correct
28 Correct 30 ms 15608 KB Output is correct
29 Correct 33 ms 15580 KB Output is correct
30 Correct 91 ms 15732 KB Output is correct
31 Correct 77 ms 15864 KB Output is correct
32 Correct 93 ms 15868 KB Output is correct
33 Correct 183 ms 26360 KB Output is correct
34 Correct 173 ms 26360 KB Output is correct
35 Incorrect 318 ms 26992 KB Output isn't correct
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 14464 KB Output is correct
2 Correct 15 ms 14464 KB Output is correct
3 Correct 15 ms 14464 KB Output is correct
4 Correct 15 ms 14464 KB Output is correct
5 Correct 15 ms 14464 KB Output is correct
6 Correct 18 ms 14464 KB Output is correct
7 Correct 15 ms 14464 KB Output is correct
8 Correct 15 ms 14456 KB Output is correct
9 Correct 14 ms 14464 KB Output is correct
10 Correct 14 ms 14464 KB Output is correct
11 Correct 14 ms 14464 KB Output is correct
12 Correct 14 ms 14464 KB Output is correct
13 Correct 14 ms 14464 KB Output is correct
14 Correct 15 ms 14464 KB Output is correct
15 Correct 14 ms 14464 KB Output is correct
16 Correct 17 ms 14592 KB Output is correct
17 Correct 16 ms 14592 KB Output is correct
18 Correct 19 ms 14592 KB Output is correct
19 Correct 19 ms 15096 KB Output is correct
20 Correct 23 ms 15096 KB Output is correct
21 Correct 24 ms 15104 KB Output is correct
22 Correct 42 ms 15096 KB Output is correct
23 Correct 43 ms 15096 KB Output is correct
24 Correct 44 ms 15224 KB Output is correct
25 Correct 40 ms 15232 KB Output is correct
26 Correct 43 ms 15224 KB Output is correct
27 Correct 1157 ms 50684 KB Output is correct
28 Correct 1748 ms 50768 KB Output is correct
29 Correct 1705 ms 51928 KB Output is correct
30 Correct 726 ms 50680 KB Output is correct
31 Execution timed out 3043 ms 47352 KB Time limit exceeded
32 Halted 0 ms 0 KB -