#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;}
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return mask & (-mask);}
ll pop_cnt(ll mask){return __builtin_popcountll(mask);}
ll ctz(ll mask){return __builtin_ctzll(mask);}
ll clz(ll mask){return __builtin_clzll(mask);}
ll logOf(ll mask){return 63 - clz(mask);}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b){a = b; return true;}
return false;
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b){a = b; return true;}
return false;
}
template <class T>
void printArr(T& a, string separator = " ", string finish = "\n", ostream& out = cout){
for(auto i: a) out << i << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
const int N = 3e5 + 69;
array<int, 3> a[N];
bool visited[N];
int ans[N];
ll sqr(ll x){return x * x;}
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
for(int i = 1; i<=n; ++i) {
for(int j = 0; j < 3; ++j) cin >> a[i][j];
}
int excessive_cnt = 0;
while(true){
int ma = 0;
for(int i = 1; i<=n; ++i) if (!visited[i])
if (ma == 0 || a[ma][2] < a[i][2]) ma = i;
if (ma == 0) break;
for(int i = 1; i<=n; ++i) if (!visited[i]){
if (sqr(a[i][0] - a[ma][0]) + sqr(a[i][1] - a[ma][1]) <= sqr(a[i][2] + a[ma][2])){
visited[i] = 1;
ans[i] = ma;
}
else if (abs(a[i][0] - a[ma][0]) + abs(a[i][1] - a[ma][1]) <= abs(a[i][2] + a[ma][2])) excessive_cnt++;
}
}
if (excessive_cnt >= 10000) exit(1);
for(int i = 1; i<=n; ++i) cout << ans[i] << " "; cout << "\n";
return 0;
}
Compilation message
circle_selection.cpp: In function 'int main()':
circle_selection.cpp:78:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
78 | for(int i = 1; i<=n; ++i) cout << ans[i] << " "; cout << "\n";
| ^~~
circle_selection.cpp:78:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
78 | for(int i = 1; i<=n; ++i) cout << ans[i] << " "; cout << "\n";
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2408 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2480 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2516 KB |
Output is correct |
20 |
Correct |
2 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
130 ms |
2536 KB |
Output is correct |
23 |
Correct |
125 ms |
2512 KB |
Output is correct |
24 |
Correct |
126 ms |
2520 KB |
Output is correct |
25 |
Correct |
124 ms |
2392 KB |
Output is correct |
26 |
Correct |
126 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
7492 KB |
Output is correct |
2 |
Correct |
97 ms |
7504 KB |
Output is correct |
3 |
Correct |
79 ms |
7104 KB |
Output is correct |
4 |
Correct |
75 ms |
7372 KB |
Output is correct |
5 |
Execution timed out |
3026 ms |
5200 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Execution timed out |
3075 ms |
4724 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3026 ms |
5460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2408 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2480 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2516 KB |
Output is correct |
20 |
Correct |
2 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
130 ms |
2536 KB |
Output is correct |
23 |
Correct |
125 ms |
2512 KB |
Output is correct |
24 |
Correct |
126 ms |
2520 KB |
Output is correct |
25 |
Correct |
124 ms |
2392 KB |
Output is correct |
26 |
Correct |
126 ms |
2644 KB |
Output is correct |
27 |
Correct |
3 ms |
2396 KB |
Output is correct |
28 |
Correct |
3 ms |
2396 KB |
Output is correct |
29 |
Correct |
3 ms |
2396 KB |
Output is correct |
30 |
Correct |
607 ms |
2644 KB |
Output is correct |
31 |
Correct |
601 ms |
2396 KB |
Output is correct |
32 |
Correct |
616 ms |
2640 KB |
Output is correct |
33 |
Correct |
29 ms |
5216 KB |
Output is correct |
34 |
Correct |
29 ms |
5212 KB |
Output is correct |
35 |
Correct |
37 ms |
5252 KB |
Output is correct |
36 |
Execution timed out |
3015 ms |
4688 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2408 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2480 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2516 KB |
Output is correct |
20 |
Correct |
2 ms |
2396 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
130 ms |
2536 KB |
Output is correct |
23 |
Correct |
125 ms |
2512 KB |
Output is correct |
24 |
Correct |
126 ms |
2520 KB |
Output is correct |
25 |
Correct |
124 ms |
2392 KB |
Output is correct |
26 |
Correct |
126 ms |
2644 KB |
Output is correct |
27 |
Correct |
76 ms |
7492 KB |
Output is correct |
28 |
Correct |
97 ms |
7504 KB |
Output is correct |
29 |
Correct |
79 ms |
7104 KB |
Output is correct |
30 |
Correct |
75 ms |
7372 KB |
Output is correct |
31 |
Execution timed out |
3026 ms |
5200 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |