#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define inF freopen("cardgame.in" , "r" , stdin);
#define outF freopen("cardgame.out" , "w" , stdout);
#define imod(a , n) (a % n + n ) % n
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;
#define ll long long
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
//#define int ll
const int N = 2e5 + 3, M = N * 4 , MX = 2e4 + 40;
const ll MOD = 998244353 , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;
int di[] = {1 , -1 , 0 , 0};
int dj[] = {0 , 0 , 1 , -1};
struct data{
double x , y , r ;
};
bool compare(data a , data b){
return a.r < b.r ;
}
int32_t main()
{
// inF;
// inF;outF;
fastio;
//Welcome back without <TAWJIHI>
int n ;
cin >> n ;
int ans[n];
memset(ans , -1 , sizeof ans);
vector<data> v(n);
for(int i = 0 ; i < n ; i ++){
cin >> v[i].x >> v[i].y >> v[i].r ;
}
int cnt = n ;
while(cnt){
int pos = 0 ;
data mx;
mx.r = 0 ;
for(int i = 0 ; i < n ; i ++){
if(ans[i] != -1)continue ;
if(compare(mx , v[i]))pos = i , mx = v[i];
}
ans[pos] = pos + 1 ;
cnt -- ;
for(int i = 0 ; i < n ; i ++){
if(ans[i] != -1)continue ;
double d = sqrt((mx.x - v[i].x) * (mx.x - v[i].x) + (mx.y - v[i].y) * (mx.y - v[i].y));
double d2 = mx.r + v[i].r ;
if(d <= d2){
ans[i] = pos + 1 ;
cnt -- ;
}
}
}
for(int i = 0 ; i < n ; i ++)cout << ans[i] << " " ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
588 KB |
Output is correct |
21 |
Correct |
6 ms |
616 KB |
Output is correct |
22 |
Correct |
132 ms |
568 KB |
Output is correct |
23 |
Correct |
132 ms |
568 KB |
Output is correct |
24 |
Correct |
154 ms |
576 KB |
Output is correct |
25 |
Correct |
129 ms |
576 KB |
Output is correct |
26 |
Correct |
128 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
227 ms |
17384 KB |
Output is correct |
2 |
Correct |
239 ms |
17264 KB |
Output is correct |
3 |
Correct |
228 ms |
16968 KB |
Output is correct |
4 |
Correct |
222 ms |
17352 KB |
Output is correct |
5 |
Execution timed out |
3050 ms |
13132 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
3078 ms |
5728 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3072 ms |
16316 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
588 KB |
Output is correct |
21 |
Correct |
6 ms |
616 KB |
Output is correct |
22 |
Correct |
132 ms |
568 KB |
Output is correct |
23 |
Correct |
132 ms |
568 KB |
Output is correct |
24 |
Correct |
154 ms |
576 KB |
Output is correct |
25 |
Correct |
129 ms |
576 KB |
Output is correct |
26 |
Correct |
128 ms |
592 KB |
Output is correct |
27 |
Correct |
9 ms |
852 KB |
Output is correct |
28 |
Correct |
9 ms |
916 KB |
Output is correct |
29 |
Correct |
12 ms |
848 KB |
Output is correct |
30 |
Correct |
560 ms |
852 KB |
Output is correct |
31 |
Correct |
599 ms |
852 KB |
Output is correct |
32 |
Correct |
565 ms |
864 KB |
Output is correct |
33 |
Correct |
88 ms |
6876 KB |
Output is correct |
34 |
Correct |
88 ms |
6756 KB |
Output is correct |
35 |
Correct |
105 ms |
6500 KB |
Output is correct |
36 |
Execution timed out |
3051 ms |
5584 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
596 KB |
Output is correct |
20 |
Correct |
5 ms |
588 KB |
Output is correct |
21 |
Correct |
6 ms |
616 KB |
Output is correct |
22 |
Correct |
132 ms |
568 KB |
Output is correct |
23 |
Correct |
132 ms |
568 KB |
Output is correct |
24 |
Correct |
154 ms |
576 KB |
Output is correct |
25 |
Correct |
129 ms |
576 KB |
Output is correct |
26 |
Correct |
128 ms |
592 KB |
Output is correct |
27 |
Correct |
227 ms |
17384 KB |
Output is correct |
28 |
Correct |
239 ms |
17264 KB |
Output is correct |
29 |
Correct |
228 ms |
16968 KB |
Output is correct |
30 |
Correct |
222 ms |
17352 KB |
Output is correct |
31 |
Execution timed out |
3050 ms |
13132 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |