답안 #106545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106545 2019-04-19T03:27:53 Z username 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 36796 KB
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<int,int> pii;
#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) ((x)*(x))

const int maxn=3e5+3,inf=1ll<<60,bl=2e9+3;
struct C{int x,y,r,id;}a[maxn];
int n,res[maxn];
bitset<maxn>rmv;
unordered_map<int,vector<int>>mp;
 
main(){
	IOS;
	cin>>n;
	int mnx=inf,mny=inf;
	REP(i,0,n)cin>>a[i].x>>a[i].y>>a[i].r,a[i].id=i,mnx=min(mnx,a[i].x),mny=min(mny,a[i].y);
	REP(i,0,n)a[i].x-=mnx,a[i].y-=mny;
	sort(a,a+n,[](C x,C y){return x.r==y.r?x.id<y.id:x.r>y.r;});
	int k=inf;
	REP(i,0,n){
		if(rmv[i])continue;
		if(2*a[i].r<inf){
			k=a[i].r;
			mp.clear();
			REP(j,i,n)if(!rmv[j])mp[a[j].x/k*bl+a[j].y/k].pb(j);
		}
		int xx=a[i].x/k,yy=a[i].y/k;
		REP(x,xx-2,xx+3)REP(y,yy-2,yy+3){
			auto&tls=mp[x*bl+y];
			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)cout<<res[i]+1<<" ";
}

Compilation message

circle_selection.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 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 2 ms 384 KB Output is correct
5 Correct 2 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 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 5 ms 640 KB Output is correct
20 Correct 6 ms 640 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 2292 ms 1172 KB Output is correct
23 Correct 2547 ms 1144 KB Output is correct
24 Correct 2350 ms 1024 KB Output is correct
25 Correct 2157 ms 1024 KB Output is correct
26 Correct 2214 ms 1080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 217 ms 15856 KB Output is correct
2 Correct 219 ms 14644 KB Output is correct
3 Correct 192 ms 14872 KB Output is correct
4 Correct 185 ms 15632 KB Output is correct
5 Execution timed out 3020 ms 16804 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Execution timed out 3033 ms 12516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3047 ms 36796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 2 ms 384 KB Output is correct
5 Correct 2 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 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 5 ms 640 KB Output is correct
20 Correct 6 ms 640 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 2292 ms 1172 KB Output is correct
23 Correct 2547 ms 1144 KB Output is correct
24 Correct 2350 ms 1024 KB Output is correct
25 Correct 2157 ms 1024 KB Output is correct
26 Correct 2214 ms 1080 KB Output is correct
27 Correct 9 ms 984 KB Output is correct
28 Correct 11 ms 1024 KB Output is correct
29 Correct 12 ms 1024 KB Output is correct
30 Execution timed out 3024 ms 1680 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 2 ms 384 KB Output is correct
5 Correct 2 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 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 5 ms 640 KB Output is correct
20 Correct 6 ms 640 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 2292 ms 1172 KB Output is correct
23 Correct 2547 ms 1144 KB Output is correct
24 Correct 2350 ms 1024 KB Output is correct
25 Correct 2157 ms 1024 KB Output is correct
26 Correct 2214 ms 1080 KB Output is correct
27 Correct 217 ms 15856 KB Output is correct
28 Correct 219 ms 14644 KB Output is correct
29 Correct 192 ms 14872 KB Output is correct
30 Correct 185 ms 15632 KB Output is correct
31 Execution timed out 3020 ms 16804 KB Time limit exceeded
32 Halted 0 ms 0 KB -