Submission #407662

# Submission time Handle Problem Language Result Execution time Memory
407662 2021-05-19T04:15:20 Z amunduzbaev Circle selection (APIO18_circle_selection) C++14
7 / 100
1923 ms 1048580 KB
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define int long long
#define pii pair<int, int>
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define lb lower_bound
#define ub upper_bound

const int N = 3e5+5;
const int M = 5e3+5;
const int mod = 1e9+7;

int n, m, k, a[N];
int rr[N];
pii p[N];

bool cmp(pii a, pii b){
	if(a.ff != b.ff) return a.ff > b.ff;
	return a.ss < b.ss; 
} int sq(int x) { return x * x; } 
int dis(int i, int j){ pii a = p[i], b = p[j];
	return sqrt(sq(a.ff - b.ff) + sq(a.ss - b.ss)); 
} 

signed main(){
	cin>>n;
	if(n <= 5000) {
		vector<pii> tt;
		for(int i=0;i<n;i++) cin>>p[i].ff>>p[i].ss>>a[i], tt.pb({a[i], i});
		sort(all(tt), cmp);
		for(auto x : tt){
			if(rr[x.ss]) continue;
			for(int i=0;i<n;i++){
				if(rr[i]) continue;
				if(dis(x.ss, i) <= a[x.ss] + a[i]) rr[i] = x.ss+1;
			}
		} 
	} else {
		vector<pii> tt;
		for(int i=0;i<n;i++) cin>>p[i].ff>>p[i].ss>>a[i], tt.pb({a[i], i});
		sort(all(tt), cmp);
		set<pii> ss;
		for(int i=0;i<n;i++) ss.insert({p[i].ff - a[i], i}), ss.insert({p[i].ff + a[i], i});
		for(auto x : tt){
			if(rr[x.ss]) continue;
			int l = p[x.ss].ff - x.ff, r = p[x.ss].ff + x.ff;
			auto lx = ss.find(make_pair(l, x.ss));
			vector<pii> er;
			while(lx != ss.end() && (*lx).ff <= r){
				er.pb(*lx);
				rr[(*lx).ss] = x.ss + 1;
			} for(auto x : er) ss.erase(x);
		}
	}
	for(int i=0;i<n;i++) cout<<rr[i]<<" ";
	cout<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 9 ms 596 KB Output is correct
20 Correct 9 ms 588 KB Output is correct
21 Correct 10 ms 588 KB Output is correct
22 Correct 114 ms 588 KB Output is correct
23 Correct 108 ms 684 KB Output is correct
24 Correct 115 ms 676 KB Output is correct
25 Correct 165 ms 588 KB Output is correct
26 Correct 108 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1923 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1176 ms 1048580 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1884 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 9 ms 596 KB Output is correct
20 Correct 9 ms 588 KB Output is correct
21 Correct 10 ms 588 KB Output is correct
22 Correct 114 ms 588 KB Output is correct
23 Correct 108 ms 684 KB Output is correct
24 Correct 115 ms 676 KB Output is correct
25 Correct 165 ms 588 KB Output is correct
26 Correct 108 ms 628 KB Output is correct
27 Runtime error 925 ms 1048580 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 9 ms 596 KB Output is correct
20 Correct 9 ms 588 KB Output is correct
21 Correct 10 ms 588 KB Output is correct
22 Correct 114 ms 588 KB Output is correct
23 Correct 108 ms 684 KB Output is correct
24 Correct 115 ms 676 KB Output is correct
25 Correct 165 ms 588 KB Output is correct
26 Correct 108 ms 628 KB Output is correct
27 Runtime error 1923 ms 1048580 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -