Submission #216462

# Submission time Handle Problem Language Result Execution time Memory
216462 2020-03-27T10:27:42 Z theStaticMind Circle selection (APIO18_circle_selection) C++14
0 / 100
502 ms 39832 KB
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

struct circle{
	int x, y, r, id;
	bool operator<(const circle& a)const{
		return x < a.x || (x == a.x && id < a.id);
	}
};

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	set<circle> X;
	vector<circle> data;

	int n;
	cin >> n;
	vector<int> ans(n, -1);

	for(int i = 0; i < n; i++){
		int x, y, r;
		cin >> x >> y >> r;
		X.insert({x, y, r, i});
		data.pb({x, y, r, i});
	}
	sort(all(data), [&](circle a, circle b){return a.r > b.r || (a.r == b.r && a.id < b.id);});

	for(auto c : data){
		if(ans[c.id] >= 0) continue;

		auto itr = X.find(c); assert(itr != X.end());
		
		while(next(itr) != X.end() && next(itr)->x - itr->x <= next(itr)->r + itr->r){
			ans[next(itr)->id] = itr->id;
			X.erase(next(itr));
		}

		while(itr != X.begin() && itr->x - prev(itr)->x <= prev(itr)->r + itr->r){
			ans[prev(itr)->id] = itr->id;
			X.erase(prev(itr));
		}
		ans[itr->id] = itr->id;
		X.erase(itr);
	}

	for(int i = 0; i < n; i++){
		cout << ans[i] + 1 << " ";
	}
	
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 482 ms 39832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 502 ms 39804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -