이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// oooo
/*
har chi delet mikhad bebar ~
gitar o ba khodet nabar! ~
;Amoo_Hasan;
*/
#include<bits/stdc++.h>
//#pragma GCC optimize("O3,no-stack-protector,unroll-loops")
//#pragma GCC target("avx2,fma")
using namespace std;
typedef long long ll;
typedef long double ld;
#define Sz(x) int((x).size())
#define All(x) (x).begin(), (x).end()
#define wtf(x) cout<<#x <<" : " <<x <<endl
constexpr ll inf = 1e18, N = 1e6 + 10, mod = 1e9 + 7, pr = 1000696969;
int x[N], y[N], r[N], ans[N];
bool mark[N];
vector<int> adj[N];
bool Ok(int i, int j) {
ll cur = 1ll * (x[i] - x[j]) * (x[i] - x[j]);
cur += 1ll * (y[i] - y[j]) * (y[i] - y[j]);
if(cur <= 1ll * (r[i] + r[j]) * (r[i] + r[j])) return true;
return false;
}
bool cmp(int i, int j) {
return r[i] > r[j];
}
int main() {
ios :: sync_with_stdio(0), cin.tie(0);
int n; cin >>n;
for(int i = 0; i < n; i++) cin >>x[i] >>y[i] >>r[i];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++) {
if(Ok(i, j)) {
adj[i].push_back(j);
adj[j].push_back(i);
}
}
vector<int> vc;
for(int i = 0; i < n; i++) vc.push_back(i);
sort(All(vc), cmp);
for(auto i : vc) {
if(mark[i]) continue;
ans[i] = i;
for(auto j : adj[i]) {
if(!mark[j]) {
mark[j] = 1;
ans[j] = i;
}
}
}
for(int i = 0; i < n; i++) cout<<ans[i] + 1 <<' ';
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... |