Submission #172299

# Submission time Handle Problem Language Result Execution time Memory
172299 2020-01-01T04:33:20 Z eggag32 Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 30504 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

bool cmp(pair<pair<ld, int>, pair<ld, ld>> a, pair<pair<ld, int>, pair<ld, ld>> b){
	if(a.fi.fi != b.fi.fi) return (a.fi.fi > b.fi.fi);
	return (a.fi.se < b.fi.se);
}

ld dist(ld x, ld y, ld x1, ld y1){
	return sqrtl(sq(x1 - x) + sq(y1 - y));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<pair<pair<ld, int>, pair<ld, ld>>> c(n);
	rep(i, n){
		cin >> c[i].se.fi >> c[i].se.se >> c[i].fi.fi;
		c[i].fi.se = i;
	}
	sort(all(c), cmp);
	vi vis(n, 0);
	vi ans(n, 0);
	//they are sorted in the way they appear
	rep(i, n) if(!vis[i]){
		repn(j, i + 1, n) if(!vis[j]){
			if(dist(c[i].se.fi, c[i].se.se, c[j].se.fi, c[j].se.se) <= (c[i].fi.fi + c[j].fi.fi)){
				//they intersect
				vis[j] = 1;
				ans[c[j].fi.se] = c[i].fi.se;
			}
		}
		vis[i] = 1;
		ans[c[i].fi.se] = c[i].fi.se;
	}
	rep(i, n) cout << ans[i] + 1 << " ";
	cout << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 10 ms 888 KB Output is correct
20 Correct 10 ms 888 KB Output is correct
21 Correct 10 ms 888 KB Output is correct
22 Correct 125 ms 888 KB Output is correct
23 Correct 125 ms 888 KB Output is correct
24 Correct 125 ms 892 KB Output is correct
25 Correct 125 ms 888 KB Output is correct
26 Correct 125 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 475 ms 30340 KB Output is correct
2 Correct 483 ms 30456 KB Output is correct
3 Correct 485 ms 30224 KB Output is correct
4 Correct 477 ms 30504 KB Output is correct
5 Execution timed out 3094 ms 26148 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Execution timed out 3023 ms 10228 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3040 ms 29424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 10 ms 888 KB Output is correct
20 Correct 10 ms 888 KB Output is correct
21 Correct 10 ms 888 KB Output is correct
22 Correct 125 ms 888 KB Output is correct
23 Correct 125 ms 888 KB Output is correct
24 Correct 125 ms 892 KB Output is correct
25 Correct 125 ms 888 KB Output is correct
26 Correct 125 ms 888 KB Output is correct
27 Correct 19 ms 1400 KB Output is correct
28 Correct 18 ms 1400 KB Output is correct
29 Correct 19 ms 1472 KB Output is correct
30 Correct 483 ms 1400 KB Output is correct
31 Correct 480 ms 1400 KB Output is correct
32 Correct 481 ms 1424 KB Output is correct
33 Correct 175 ms 11156 KB Output is correct
34 Correct 175 ms 11140 KB Output is correct
35 Correct 172 ms 11144 KB Output is correct
36 Execution timed out 3044 ms 9976 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 4 ms 504 KB Output is correct
19 Correct 10 ms 888 KB Output is correct
20 Correct 10 ms 888 KB Output is correct
21 Correct 10 ms 888 KB Output is correct
22 Correct 125 ms 888 KB Output is correct
23 Correct 125 ms 888 KB Output is correct
24 Correct 125 ms 892 KB Output is correct
25 Correct 125 ms 888 KB Output is correct
26 Correct 125 ms 888 KB Output is correct
27 Correct 475 ms 30340 KB Output is correct
28 Correct 483 ms 30456 KB Output is correct
29 Correct 485 ms 30224 KB Output is correct
30 Correct 477 ms 30504 KB Output is correct
31 Execution timed out 3094 ms 26148 KB Time limit exceeded
32 Halted 0 ms 0 KB -