This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
typedef long long ll;
const ll MAX = 2147483647;
ll dis(pll a, pll b){
ll x = a.F - b.F;
ll y = a.S - b.S;
return x * x + y *y ;
}
struct Comp{
bool operator()(pll a, pll b){
if(a.F == b.F) return a.S < b.S;
return a.F > b.F;
}
};
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<ll, pll>> c(n);
for(int i = 0; i < n; i++){
cin >> c[i].S.F >> c[i].S.S >> c[i].F;
}
vector<int> a(n);
vector<vector<int>> is(n);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(dis(c[i].S, c[j].S) <= (c[i].F + c[j].F) * (c[i].F + c[j].F))
is[i].eb(j);
}
}
set<pll, Comp> pq;
for(int i = 0; i < n; i++) pq.insert(mp(c[i].F, i));
while(!pq.empty()){
int now = pq.begin()->S;
pq.erase(pq.begin());
a[now] = now;
for(int i : is[now]){
if(pq.find(mp(c[i].F, i)) != pq.end()){
a[i] = now;
pq.erase(mp(c[i].F, i));
}
}
}
for(int i = 0; i < n; i++) cout << a[i] + 1 << " ";
cout << "\n";
return 0;
}
# | 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... |