이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Null
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
const ll Mod = 1000000007LL;
const int N = 5e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;
ll x[N], y[N], r[N];
ll ans[N];
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> y[i] >> r[i];
}
while(true){
int idx = -1;
int mx = -1;
for(int i = n; i >= 1; i--){
if(ans[i]) continue;
if(r[i] >= mx){
idx = i;
mx = r[i];
}
}
if(idx == -1) break;
for(int i = 1; i <= n; i++){
if(ans[i]) continue;
ll dis = (x[i] - x[idx]) * (x[i] - x[idx]) + (y[i] - y[idx]) * (y[i] - y[idx]);
ll rq = r[i] * r[i] + r[idx] * r[idx] + 2 * r[i] * r[idx];
if(rq >= dis) ans[i] = idx;
}
}
for(int i = 1; i <= n; i++) cout << ans[i] << ' ';
cout << '\n';
return 0;
}
/*
11
9 9 2
13 2 1
11 8 2
3 3 2
3 12 1
12 14 1
9 8 5
2 8 2
5 2 1
14 4 2
14 14 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |