// 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], rad[N], ans[N], l[N], r[N];
bool mark[N];
vector<int> adj[N], vc, po;
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 * (rad[i] + rad[j]) * (rad[i] + rad[j])) return true;
return false;
}
bool cmp(int i, int j) {
return y[i] > y[j];
}
bool cmp2(int i, int j) {
return rad[vc[i]] < rad[vc[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] >>rad[i];
for(int i = 0; i < n; i++) vc.push_back(i), po.push_back(i);
sort(All(vc), cmp), sort(All(po), cmp2);
for(int i = 0; i < Sz(vc); i++) {
l[i] = i - 1, r[i] = i + 1;
}
int tim = n;
while(tim--) {
int pos = po.back(); po.pop_back();
if(mark[vc[pos]]) continue;
mark[vc[pos]] = 1, ans[vc[pos]] = vc[pos];
int ind = pos;
pos = l[ind];
while(pos != -1 && Ok(vc[pos], vc[ind])) {
mark[vc[pos]] = 1;
ans[vc[pos]] = vc[ind];
int nxt = l[pos];
r[l[pos]] = ind, l[ind] = l[pos];
pos = nxt;
}
pos = r[ind];
while(pos != n && Ok(vc[pos], vc[ind])) {
mark[vc[pos]] = 1;
ans[vc[pos]] = vc[ind];
int nxt = r[pos];
l[r[pos]] = ind, r[ind] = r[pos];
pos = nxt;
}
}
for(int i = 0; i < n; i++) cout<<ans[i] + 1 <<' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
14 ms |
23764 KB |
Output is correct |
3 |
Correct |
14 ms |
23764 KB |
Output is correct |
4 |
Correct |
12 ms |
23852 KB |
Output is correct |
5 |
Correct |
13 ms |
23836 KB |
Output is correct |
6 |
Correct |
13 ms |
23740 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
8 |
Incorrect |
12 ms |
23864 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
178 ms |
35840 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Incorrect |
92 ms |
27828 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
179 ms |
35676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
14 ms |
23764 KB |
Output is correct |
3 |
Correct |
14 ms |
23764 KB |
Output is correct |
4 |
Correct |
12 ms |
23852 KB |
Output is correct |
5 |
Correct |
13 ms |
23836 KB |
Output is correct |
6 |
Correct |
13 ms |
23740 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
8 |
Incorrect |
12 ms |
23864 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
14 ms |
23764 KB |
Output is correct |
3 |
Correct |
14 ms |
23764 KB |
Output is correct |
4 |
Correct |
12 ms |
23852 KB |
Output is correct |
5 |
Correct |
13 ms |
23836 KB |
Output is correct |
6 |
Correct |
13 ms |
23740 KB |
Output is correct |
7 |
Correct |
13 ms |
23760 KB |
Output is correct |
8 |
Incorrect |
12 ms |
23864 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |