Submission #99821

# Submission time Handle Problem Language Result Execution time Memory
99821 2019-03-07T16:26:21 Z TadijaSebez Circle selection (APIO18_circle_selection) C++11
37 / 100
3000 ms 181828 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);}
const int N=300050;
circle a[N];
int ans[N];
map<pair<int,int>,int> id;
vector<circle> 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;
	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> p=mp(floor((double)a[i].x/po),floor((double)a[i].y/po));
			if(!id[p]) id[p]=++cnt,all[cnt].clear();
			all[id[p]].pb(a[i]);
		}
		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++) for(int r=-2;r<=2;r++)
			{
				int idx=id[mp(x+l,y+r)];
				if(!idx) continue;
				vector<circle> v=all[idx],e;
				for(circle c:v)
				{
					if(sec(c,a[i])) ans[c.id]=a[i].id;
					else e.pb(c);
				}
				all[idx]=e;
			}
		}
	}
	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:19: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:31: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:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
circle_selection.cpp:18:67: 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;
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 9 ms 7424 KB Output is correct
4 Correct 10 ms 7424 KB Output is correct
5 Correct 10 ms 7424 KB Output is correct
6 Correct 8 ms 7424 KB Output is correct
7 Correct 8 ms 7424 KB Output is correct
8 Correct 10 ms 7424 KB Output is correct
9 Correct 9 ms 7552 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 9 ms 7424 KB Output is correct
12 Correct 10 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 10 ms 7552 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 10 ms 7524 KB Output is correct
17 Correct 9 ms 7552 KB Output is correct
18 Correct 9 ms 7424 KB Output is correct
19 Correct 17 ms 7936 KB Output is correct
20 Correct 13 ms 7936 KB Output is correct
21 Correct 14 ms 8064 KB Output is correct
22 Correct 74 ms 12344 KB Output is correct
23 Correct 78 ms 12660 KB Output is correct
24 Correct 76 ms 11636 KB Output is correct
25 Correct 77 ms 12024 KB Output is correct
26 Correct 99 ms 12280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 387 ms 33588 KB Output is correct
2 Correct 367 ms 44720 KB Output is correct
3 Correct 373 ms 39632 KB Output is correct
4 Correct 416 ms 38104 KB Output is correct
5 Correct 875 ms 96316 KB Output is correct
6 Execution timed out 3049 ms 171964 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7424 KB Output is correct
2 Correct 2412 ms 102388 KB Output is correct
3 Execution timed out 3028 ms 124852 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3034 ms 133200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 9 ms 7424 KB Output is correct
4 Correct 10 ms 7424 KB Output is correct
5 Correct 10 ms 7424 KB Output is correct
6 Correct 8 ms 7424 KB Output is correct
7 Correct 8 ms 7424 KB Output is correct
8 Correct 10 ms 7424 KB Output is correct
9 Correct 9 ms 7552 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 9 ms 7424 KB Output is correct
12 Correct 10 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 10 ms 7552 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 10 ms 7524 KB Output is correct
17 Correct 9 ms 7552 KB Output is correct
18 Correct 9 ms 7424 KB Output is correct
19 Correct 17 ms 7936 KB Output is correct
20 Correct 13 ms 7936 KB Output is correct
21 Correct 14 ms 8064 KB Output is correct
22 Correct 74 ms 12344 KB Output is correct
23 Correct 78 ms 12660 KB Output is correct
24 Correct 76 ms 11636 KB Output is correct
25 Correct 77 ms 12024 KB Output is correct
26 Correct 99 ms 12280 KB Output is correct
27 Correct 17 ms 8568 KB Output is correct
28 Correct 16 ms 8440 KB Output is correct
29 Correct 17 ms 8432 KB Output is correct
30 Correct 159 ms 18288 KB Output is correct
31 Correct 133 ms 18032 KB Output is correct
32 Correct 157 ms 16112 KB Output is correct
33 Correct 132 ms 17320 KB Output is correct
34 Correct 101 ms 17248 KB Output is correct
35 Correct 127 ms 18784 KB Output is correct
36 Correct 2665 ms 113052 KB Output is correct
37 Correct 2735 ms 103300 KB Output is correct
38 Correct 2729 ms 112564 KB Output is correct
39 Correct 1189 ms 44968 KB Output is correct
40 Correct 908 ms 45172 KB Output is correct
41 Correct 880 ms 45940 KB Output is correct
42 Correct 589 ms 42008 KB Output is correct
43 Correct 2162 ms 180276 KB Output is correct
44 Correct 2406 ms 181828 KB Output is correct
45 Correct 2212 ms 180408 KB Output is correct
46 Correct 2180 ms 180156 KB Output is correct
47 Correct 2143 ms 180664 KB Output is correct
48 Correct 2208 ms 181564 KB Output is correct
49 Correct 2164 ms 181436 KB Output is correct
50 Correct 2117 ms 180224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 9 ms 7424 KB Output is correct
4 Correct 10 ms 7424 KB Output is correct
5 Correct 10 ms 7424 KB Output is correct
6 Correct 8 ms 7424 KB Output is correct
7 Correct 8 ms 7424 KB Output is correct
8 Correct 10 ms 7424 KB Output is correct
9 Correct 9 ms 7552 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 9 ms 7424 KB Output is correct
12 Correct 10 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 10 ms 7552 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 10 ms 7524 KB Output is correct
17 Correct 9 ms 7552 KB Output is correct
18 Correct 9 ms 7424 KB Output is correct
19 Correct 17 ms 7936 KB Output is correct
20 Correct 13 ms 7936 KB Output is correct
21 Correct 14 ms 8064 KB Output is correct
22 Correct 74 ms 12344 KB Output is correct
23 Correct 78 ms 12660 KB Output is correct
24 Correct 76 ms 11636 KB Output is correct
25 Correct 77 ms 12024 KB Output is correct
26 Correct 99 ms 12280 KB Output is correct
27 Correct 387 ms 33588 KB Output is correct
28 Correct 367 ms 44720 KB Output is correct
29 Correct 373 ms 39632 KB Output is correct
30 Correct 416 ms 38104 KB Output is correct
31 Correct 875 ms 96316 KB Output is correct
32 Execution timed out 3049 ms 171964 KB Time limit exceeded
33 Halted 0 ms 0 KB -