Submission #698766

# Submission time Handle Problem Language Result Execution time Memory
698766 2023-02-14T09:32:47 Z vjudge1 Circle selection (APIO18_circle_selection) C++17
7 / 100
3000 ms 12916 KB
#include <bits/stdc++.h>
#include <array>
#define all(v) (v.begin()), (v.end())
#define setall(a, val) for(auto& x : a) x = val
#define ll long long
clock_t start_time;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init() {
#ifndef ONLINE_JUDGE
	FILE* _ = freopen("in.txt", "r", stdin);
	start_time = clock();
#endif
}
const ll MOD = 998244353;
const ll N = 6e5 + 1;
const ll M = 2e2 + 1;
using namespace std;
//####################################################################################

bool comp(array<ll, 4> a, array<ll, 4> b) {
	if (a[0] == b[0])
		return a[3] < b[3];
	return a[0] > b[0];
}

double dist(ll x1, ll y1, ll x2, ll y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); //init();

	int n;
	cin >> n;
	vector< array<ll, 4> > v(n); // {radius, x, y, idx}
	for (int i = 0; i < n; i++)
		cin >> v[i][1] >> v[i][2] >> v[i][0], v[i][3] = i + 1;
	sort(all(v), comp);

	vector<int> ans(n + 1, 0);
	for (int i = 0; i < n; i++) {
		if (ans[v[i][3]])
			continue;
		ans[v[i][3]] = v[i][3];
		for (int j = i + 1; j < n; j++) {
			if (!ans[v[j][3]] && dist(v[i][1], v[i][2], v[j][1], v[j][2]) <= v[i][0] + v[j][0])
				ans[v[j][3]] = v[i][3];
		}
	}

	for (int i = 1; i <= n; i++)
		cout << ans[i] << ' ';
	cout << endl;

	//cerr << get_time() << "s" << endl;
}

Compilation message

circle_selection.cpp: In function 'void init()':
circle_selection.cpp:10:8: warning: unused variable '_' [-Wunused-variable]
   10 |  FILE* _ = freopen("in.txt", "r", stdin);
      |        ^
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 3 ms 468 KB Output is correct
22 Correct 38 ms 504 KB Output is correct
23 Correct 39 ms 492 KB Output is correct
24 Correct 38 ms 504 KB Output is correct
25 Correct 41 ms 496 KB Output is correct
26 Correct 39 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 156 ms 12916 KB Output is correct
2 Correct 149 ms 12908 KB Output is correct
3 Correct 147 ms 12648 KB Output is correct
4 Correct 154 ms 12912 KB Output is correct
5 Execution timed out 3088 ms 10868 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 3091 ms 3828 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3076 ms 10872 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 3 ms 468 KB Output is correct
22 Correct 38 ms 504 KB Output is correct
23 Correct 39 ms 492 KB Output is correct
24 Correct 38 ms 504 KB Output is correct
25 Correct 41 ms 496 KB Output is correct
26 Correct 39 ms 488 KB Output is correct
27 Correct 5 ms 724 KB Output is correct
28 Correct 6 ms 652 KB Output is correct
29 Correct 5 ms 724 KB Output is correct
30 Correct 150 ms 676 KB Output is correct
31 Correct 147 ms 672 KB Output is correct
32 Correct 147 ms 668 KB Output is correct
33 Correct 51 ms 4352 KB Output is correct
34 Correct 51 ms 4428 KB Output is correct
35 Correct 52 ms 4352 KB Output is correct
36 Execution timed out 3094 ms 3788 KB Time limit exceeded
37 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 3 ms 468 KB Output is correct
21 Correct 3 ms 468 KB Output is correct
22 Correct 38 ms 504 KB Output is correct
23 Correct 39 ms 492 KB Output is correct
24 Correct 38 ms 504 KB Output is correct
25 Correct 41 ms 496 KB Output is correct
26 Correct 39 ms 488 KB Output is correct
27 Correct 156 ms 12916 KB Output is correct
28 Correct 149 ms 12908 KB Output is correct
29 Correct 147 ms 12648 KB Output is correct
30 Correct 154 ms 12912 KB Output is correct
31 Execution timed out 3088 ms 10868 KB Time limit exceeded
32 Halted 0 ms 0 KB -