Submission #153244

# Submission time Handle Problem Language Result Execution time Memory
153244 2019-09-13T02:20:56 Z username Circle selection (APIO18_circle_selection) C++14
49 / 100
3000 ms 356040 KB
#include<bits/stdc++.h>
using namespace std;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define pb push_back
#define F first
#define S second
#define IOS cin.tie(0),ios_base::sync_with_stdio(false)
#define f2(x) (int64_t(x)*(x))

template<class T>
void R(T &x)
{
	x = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		x = x * 10 + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		x = -x;
	}
}
template<class T>
void P(T output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int buf[20], n = 0;
	while(output)
	{
		buf[n] = ((output % 10));
		output /= 10;
		n++;
	}
	for (n--; n >= 0; n--)
	{
		putchar(buf[n] + '0');
	}
	return;
}
 
const int maxn=3e5+3;
struct C{int x,y,r,id;}a[maxn];
int n,res[maxn];
bool rmv[maxn];
unordered_map<int64_t,vector<int>>mp;
 
main(){
	IOS;
	R(n);
	REP(i,0,n)R(a[i].x),R(a[i].y),R(a[i].r),a[i].id=i;
	sort(a,a+n,[](C&x,C&y){return x.r==y.r?x.id<y.id:x.r>y.r;});
	int k=31;
	REP(i,0,n){
		if(rmv[i])continue;
		if((a[i].r<<1)<(1ll<<k)){
			while((a[i].r<<1)<(1ll<<k))--k;
			mp.clear();
			REP(j,i,n)if(!rmv[j])mp[(int64_t(a[j].x>>k)<<31)+(a[j].y>>k)].pb(j);
		}
		int xx=a[i].x>>k,yy=a[i].y>>k;
		REP(x,xx-5,xx)REP(y,yy-5,yy){
			auto&tls=mp[(int64_t(x+3)<<31)+(y+3)];
			for(auto it=tls.begin();it!=tls.end();++it){
				if(!rmv[*it]&&f2(a[i].x-a[*it].x)+f2(a[i].y-a[*it].y)<=f2(a[i].r+a[*it].r)){
					res[a[*it].id]=a[i].id;
					rmv[*it]=1;
				}
			}
		}
	}
	REP(i,0,n)P(res[i]+1),putchar(' ');
}

Compilation message

circle_selection.cpp:68:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 6 ms 500 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 29 ms 4396 KB Output is correct
23 Correct 32 ms 4320 KB Output is correct
24 Correct 27 ms 3112 KB Output is correct
25 Correct 27 ms 3564 KB Output is correct
26 Correct 32 ms 4392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 207 ms 8832 KB Output is correct
2 Correct 211 ms 9032 KB Output is correct
3 Correct 203 ms 10168 KB Output is correct
4 Correct 203 ms 9432 KB Output is correct
5 Correct 227 ms 11816 KB Output is correct
6 Correct 1399 ms 48016 KB Output is correct
7 Correct 275 ms 13224 KB Output is correct
8 Correct 416 ms 20792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1292 ms 69364 KB Output is correct
3 Execution timed out 3053 ms 176396 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3082 ms 356040 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 6 ms 500 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 29 ms 4396 KB Output is correct
23 Correct 32 ms 4320 KB Output is correct
24 Correct 27 ms 3112 KB Output is correct
25 Correct 27 ms 3564 KB Output is correct
26 Correct 32 ms 4392 KB Output is correct
27 Correct 10 ms 888 KB Output is correct
28 Correct 9 ms 888 KB Output is correct
29 Correct 9 ms 888 KB Output is correct
30 Correct 66 ms 8748 KB Output is correct
31 Correct 67 ms 8684 KB Output is correct
32 Correct 54 ms 6252 KB Output is correct
33 Correct 81 ms 4084 KB Output is correct
34 Correct 80 ms 4084 KB Output is correct
35 Correct 78 ms 3604 KB Output is correct
36 Correct 1419 ms 74528 KB Output is correct
37 Correct 1436 ms 69924 KB Output is correct
38 Correct 1311 ms 75208 KB Output is correct
39 Correct 336 ms 9900 KB Output is correct
40 Correct 278 ms 9816 KB Output is correct
41 Correct 282 ms 9856 KB Output is correct
42 Correct 122 ms 9168 KB Output is correct
43 Correct 1391 ms 137712 KB Output is correct
44 Correct 1351 ms 137824 KB Output is correct
45 Correct 1408 ms 137784 KB Output is correct
46 Correct 2029 ms 137764 KB Output is correct
47 Correct 1363 ms 138008 KB Output is correct
48 Correct 1388 ms 138016 KB Output is correct
49 Correct 1333 ms 138016 KB Output is correct
50 Correct 1375 ms 137912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 6 ms 500 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 29 ms 4396 KB Output is correct
23 Correct 32 ms 4320 KB Output is correct
24 Correct 27 ms 3112 KB Output is correct
25 Correct 27 ms 3564 KB Output is correct
26 Correct 32 ms 4392 KB Output is correct
27 Correct 207 ms 8832 KB Output is correct
28 Correct 211 ms 9032 KB Output is correct
29 Correct 203 ms 10168 KB Output is correct
30 Correct 203 ms 9432 KB Output is correct
31 Correct 227 ms 11816 KB Output is correct
32 Correct 1399 ms 48016 KB Output is correct
33 Correct 275 ms 13224 KB Output is correct
34 Correct 416 ms 20792 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 1292 ms 69364 KB Output is correct
37 Execution timed out 3053 ms 176396 KB Time limit exceeded
38 Halted 0 ms 0 KB -