Submission #106527

# Submission time Handle Problem Language Result Execution time Memory
106527 2019-04-19T02:54:53 Z username Circle selection (APIO18_circle_selection) C++14
49 / 100
3000 ms 286352 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
//																#define __debug
#ifdef __debug
	#define IOS (void)0
	#define de(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define de(...) (void)0
	#define ar(...) (void)0
#endif
/***********************************default***********************************/
#define f2(x) ((x)*(x))
const int maxn=3e5+9,inf=1ll<<60,bl=3e9;
struct C{int x,y,r,id;}a[maxn];
int n,rmv[maxn],res[maxn];
unordered_map<int,list<int>>mp;
list<int>ls;
 
main(){
	IOS;
	cin>>n;
	REP(i,0,n)cin>>a[i].x>>a[i].y>>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;});
//	MST(rmv,0);
	int k=inf;
	REP(i,0,n){
		if(rmv[i])continue;
		if(2*a[i].r<k){
			k=a[i].r;
			mp.clear();
			REP(j,0,n){
				if(!rmv[j]){
					mp[a[j].x/k*bl+a[j].y/k].pb(j);
				}
			}
		}
		REP(x,a[i].x/k-2,a[i].x/k+3)REP(y,a[i].y/k-2,a[i].y/k+3){
			auto&tls=mp[x*bl+y];
			for(auto it=tls.begin();it!=tls.end();){
				C c=a[*it];
				if(f2(a[i].x-c.x)+f2(a[i].y-c.y)<=f2(a[i].r+c.r)){
					res[c.id]=a[i].id;
					rmv[*it]=1;
					tls.erase(it++);
				}else ++it;
			}
		}
	}
	REP(i,0,n)cout<<res[i]+1<<" ";
}

Compilation message

circle_selection.cpp:33:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 6 ms 768 KB Output is correct
20 Correct 9 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 32 ms 4616 KB Output is correct
23 Correct 36 ms 4744 KB Output is correct
24 Correct 43 ms 4744 KB Output is correct
25 Correct 39 ms 4740 KB Output is correct
26 Correct 39 ms 4872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 228 ms 26048 KB Output is correct
2 Correct 232 ms 26008 KB Output is correct
3 Correct 230 ms 25820 KB Output is correct
4 Correct 220 ms 25976 KB Output is correct
5 Correct 511 ms 26636 KB Output is correct
6 Correct 1488 ms 71164 KB Output is correct
7 Correct 593 ms 28084 KB Output is correct
8 Correct 750 ms 33348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 1629 ms 83240 KB Output is correct
3 Execution timed out 3054 ms 286352 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3063 ms 284748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 6 ms 768 KB Output is correct
20 Correct 9 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 32 ms 4616 KB Output is correct
23 Correct 36 ms 4744 KB Output is correct
24 Correct 43 ms 4744 KB Output is correct
25 Correct 39 ms 4740 KB Output is correct
26 Correct 39 ms 4872 KB Output is correct
27 Correct 9 ms 1280 KB Output is correct
28 Correct 10 ms 1280 KB Output is correct
29 Correct 9 ms 1152 KB Output is correct
30 Correct 104 ms 9076 KB Output is correct
31 Correct 102 ms 9016 KB Output is correct
32 Correct 90 ms 9148 KB Output is correct
33 Correct 88 ms 8824 KB Output is correct
34 Correct 88 ms 8824 KB Output is correct
35 Correct 102 ms 8772 KB Output is correct
36 Correct 1538 ms 84560 KB Output is correct
37 Correct 1463 ms 84312 KB Output is correct
38 Correct 1416 ms 84144 KB Output is correct
39 Correct 628 ms 26556 KB Output is correct
40 Correct 666 ms 26488 KB Output is correct
41 Correct 664 ms 26612 KB Output is correct
42 Correct 238 ms 14472 KB Output is correct
43 Correct 1648 ms 140128 KB Output is correct
44 Correct 1718 ms 140308 KB Output is correct
45 Correct 1688 ms 140076 KB Output is correct
46 Correct 1685 ms 140232 KB Output is correct
47 Correct 1707 ms 140400 KB Output is correct
48 Correct 1559 ms 140340 KB Output is correct
49 Correct 1780 ms 140468 KB Output is correct
50 Correct 1618 ms 140336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 6 ms 768 KB Output is correct
20 Correct 9 ms 768 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 32 ms 4616 KB Output is correct
23 Correct 36 ms 4744 KB Output is correct
24 Correct 43 ms 4744 KB Output is correct
25 Correct 39 ms 4740 KB Output is correct
26 Correct 39 ms 4872 KB Output is correct
27 Correct 228 ms 26048 KB Output is correct
28 Correct 232 ms 26008 KB Output is correct
29 Correct 230 ms 25820 KB Output is correct
30 Correct 220 ms 25976 KB Output is correct
31 Correct 511 ms 26636 KB Output is correct
32 Correct 1488 ms 71164 KB Output is correct
33 Correct 593 ms 28084 KB Output is correct
34 Correct 750 ms 33348 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 1629 ms 83240 KB Output is correct
37 Execution timed out 3054 ms 286352 KB Time limit exceeded
38 Halted 0 ms 0 KB -