답안 #106544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106544 2019-04-19T03:25:45 Z username 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 36744 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 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 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 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 8 ms 768 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 2048 ms 1116 KB Output is correct
23 Correct 2156 ms 1044 KB Output is correct
24 Correct 1946 ms 1024 KB Output is correct
25 Correct 2304 ms 1048 KB Output is correct
26 Correct 2180 ms 1276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 14816 KB Output is correct
2 Correct 257 ms 14876 KB Output is correct
3 Correct 254 ms 14740 KB Output is correct
4 Correct 212 ms 14696 KB Output is correct
5 Execution timed out 3060 ms 16856 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 3100 ms 12636 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3031 ms 36744 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 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 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 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 8 ms 768 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 2048 ms 1116 KB Output is correct
23 Correct 2156 ms 1044 KB Output is correct
24 Correct 1946 ms 1024 KB Output is correct
25 Correct 2304 ms 1048 KB Output is correct
26 Correct 2180 ms 1276 KB Output is correct
27 Correct 10 ms 1024 KB Output is correct
28 Correct 9 ms 896 KB Output is correct
29 Correct 12 ms 896 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 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 2 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 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 5 ms 640 KB Output is correct
20 Correct 8 ms 768 KB Output is correct
21 Correct 7 ms 640 KB Output is correct
22 Correct 2048 ms 1116 KB Output is correct
23 Correct 2156 ms 1044 KB Output is correct
24 Correct 1946 ms 1024 KB Output is correct
25 Correct 2304 ms 1048 KB Output is correct
26 Correct 2180 ms 1276 KB Output is correct
27 Correct 211 ms 14816 KB Output is correct
28 Correct 257 ms 14876 KB Output is correct
29 Correct 254 ms 14740 KB Output is correct
30 Correct 212 ms 14696 KB Output is correct
31 Execution timed out 3060 ms 16856 KB Time limit exceeded
32 Halted 0 ms 0 KB -