Submission #673845

# Submission time Handle Problem Language Result Execution time Memory
673845 2022-12-22T09:21:26 Z Dan4Life Circle selection (APIO18_circle_selection) C++17
0 / 100
3000 ms 32880 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long 
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
using ll = long long;
const int maxn = (int)3e5+10;
const ll LINF = (ll)2e18;
struct circle{
	int x, y, r, i;
};

int n, elim[maxn];
vector<circle> v;

bool intersects(int i, int j){
	int rr = v[i].r+v[j].r;
	int xx = v[i].x-v[j].x;
	int yy = v[i].y-v[j].y;
	return rr*rr>=xx*xx+yy*yy;
}

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n; v.resize(n); set<pair<int,int>> S;
	for(int i = 0; i < n; i++){
		cin >> v[i].x >> v[i].y >> v[i].r; 
		v[i].i=i; elim[i]=-1; S.insert({v[i].x, i});
	}
	sort(all(v), [&](circle &a, circle &b){
		if(a.r!=b.r) return a.r > b.r;
		return a.i < b.i;
	});
	for(int i = 0; i < n; i++){
		if(elim[v[i].i]!=-1) continue;
		for(int j = i; j < n; j++)
			if(intersects(i,j)) elim[v[j].i]=v[i].i; continue;
		while(!S.empty()){
			auto itr = S.lower_bound({v[i].x-v[i].r,-1});
			if(itr!=S.end() and itr->fi <= v[i].x) elim[itr->se]=v[i].i, S.erase(itr);
			else break;
		}
	}
	for(int i = 0; i < n; i++) cout << elim[i]+1 << " ";
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/

Compilation message

circle_selection.cpp: In function 'int32_t main()':
circle_selection.cpp:40:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   40 |    if(intersects(i,j)) elim[v[j].i]=v[i].i; continue;
      |    ^~
circle_selection.cpp:40:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   40 |    if(intersects(i,j)) elim[v[j].i]=v[i].i; continue;
      |                                             ^~~~~~~~
circle_selection.cpp:39:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   39 |   for(int j = i; j < n; j++)
      |   ^~~
circle_selection.cpp:40:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |    if(intersects(i,j)) elim[v[j].i]=v[i].i; continue;
      |                                             ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 317 ms 32880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 3062 ms 11172 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3034 ms 30736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -