#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ep insert
#define pow pwr
#define sqrt sqrtt
#define elif else if
#define y1 YONE
#define int long long
using namespace std;
const int N=1e6+5;
int n,ans[N];
pair<pair<int,int>,int> a[N];
vector<int> adj[N];
map<int,int> mp;
bool cmp(pair<pair<int,int>,int> x,pair<pair<int,int>,int> y){
if (x.F.S-x.F.F!=y.F.S-y.F.F) return x.F.S-x.F.F>y.F.S-y.F.F;
return x.S<y.S;
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n;
for (int i=1;i<=n;i++){
int x,y,r;
cin>>x>>y>>r;
a[i]={{x-r,x+r},i};
mp[x+r]++;
mp[x-r]++;
}
sort(a+1,a+1+n,cmp);
int c=0;
for (auto u:mp){
c++;
mp[u.F]=c;
}
for (int i=1;i<=n;i++){
a[i].F={mp[a[i].F.F],mp[a[i].F.S]};
adj[a[i].F.F].pb(i);
adj[a[i].F.S].pb(i);
}
for (int i=1;i<=n;i++){
if (ans[a[i].S]) continue;
for (int j=a[i].F.F;j<=a[i].F.S;j++){
for (auto u:adj[j]){
if (!ans[a[u].S]) ans[a[u].S]=a[i].S;
}adj[j].clear();
}
}
for (int i=1;i<=n;i++) cout<<ans[i]<<' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Incorrect |
14 ms |
23772 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1327 ms |
96044 KB |
Output is correct |
2 |
Correct |
1370 ms |
98408 KB |
Output is correct |
3 |
Correct |
1297 ms |
98024 KB |
Output is correct |
4 |
Correct |
1389 ms |
98336 KB |
Output is correct |
5 |
Correct |
997 ms |
68536 KB |
Output is correct |
6 |
Correct |
1008 ms |
95184 KB |
Output is correct |
7 |
Correct |
1185 ms |
89972 KB |
Output is correct |
8 |
Correct |
1062 ms |
92504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
23764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1137 ms |
93692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Incorrect |
14 ms |
23772 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Incorrect |
14 ms |
23772 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |