답안 #516906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516906 2022-01-22T08:14:58 Z shmad 원 고르기 (APIO18_circle_selection) C++17
7 / 100
3000 ms 14148 KB
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") 

#include <bits/stdc++.h>

#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define left leftt

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvi = vt< vt<int> >;

const int N = 1e6 + 5, mod = 1e9 + 7, inf = 1e18 + 7, B = 500, LIM = (1ll << 60);
const double eps = 1e-6;

int n, x[N], y[N], r[N], ans[N];

bool inter (int x1, int x2, int y1, int y2, int r1, int r2) {
	int x = x1 - x2, y = y1 - y2, r = r1 + r2;
	x *= x, y *= y, r *= r;
	return (x + y <= r);
}

void solve () {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
	vt<int> left(n + 1, 1);
	while (true) {
		bool ok = 0;
		for (int i = 1; i <= n; i++) ok |= left[i];
		if (!ok) break;
		int mx = 0, pos = 0;
		for (int i = 1; i <= n; i++) {
			if (left[i] && mx < r[i]) mx = r[i], pos = i;
		}
		for (int i = 1; i <= n; i++) {
			if (left[i] && inter(x[i], x[pos], y[i], y[pos], r[i], r[pos])) ans[i] = pos, left[i] = 0;
		}
	}
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << '\n';
}

bool testcases = 0;
                  
signed main() {
#ifdef ONLINE_JUDGE
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif
    cin.tie(0) -> sync_with_stdio(0);
    int test = 1;
    if (testcases) cin >> test;
    for (int cs = 1; cs <= test; cs++) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 460 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 3 ms 460 KB Output is correct
22 Correct 133 ms 524 KB Output is correct
23 Correct 135 ms 544 KB Output is correct
24 Correct 132 ms 524 KB Output is correct
25 Correct 130 ms 528 KB Output is correct
26 Correct 130 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 14072 KB Output is correct
2 Correct 110 ms 14136 KB Output is correct
3 Correct 126 ms 13940 KB Output is correct
4 Correct 121 ms 14148 KB Output is correct
5 Execution timed out 3067 ms 12100 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Execution timed out 3079 ms 4340 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3053 ms 9760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 460 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 3 ms 460 KB Output is correct
22 Correct 133 ms 524 KB Output is correct
23 Correct 135 ms 544 KB Output is correct
24 Correct 132 ms 524 KB Output is correct
25 Correct 130 ms 528 KB Output is correct
26 Correct 130 ms 528 KB Output is correct
27 Correct 4 ms 716 KB Output is correct
28 Correct 6 ms 772 KB Output is correct
29 Correct 4 ms 716 KB Output is correct
30 Correct 618 ms 724 KB Output is correct
31 Correct 627 ms 736 KB Output is correct
32 Correct 608 ms 728 KB Output is correct
33 Correct 37 ms 4824 KB Output is correct
34 Correct 39 ms 4756 KB Output is correct
35 Correct 54 ms 4828 KB Output is correct
36 Execution timed out 3058 ms 4252 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 460 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 3 ms 460 KB Output is correct
22 Correct 133 ms 524 KB Output is correct
23 Correct 135 ms 544 KB Output is correct
24 Correct 132 ms 524 KB Output is correct
25 Correct 130 ms 528 KB Output is correct
26 Correct 130 ms 528 KB Output is correct
27 Correct 122 ms 14072 KB Output is correct
28 Correct 110 ms 14136 KB Output is correct
29 Correct 126 ms 13940 KB Output is correct
30 Correct 121 ms 14148 KB Output is correct
31 Execution timed out 3067 ms 12100 KB Time limit exceeded
32 Halted 0 ms 0 KB -