#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=3e5+100;
const int SQ=333;// 333 444
vector<int> adj[N];
ll who[N];
void solve()
{
ll n;
cin>>n;
vector<ll> x(n),y(n),r(n);
for(int i=0;i<n;i++)
cin>>x[i]>>y[i]>>r[i];
vector<pair<ll,ll>> tp(n);
for(int i=0;i<n;i++)
{
tp[i].first=x[i];
tp[i].second=i;
}
sort(begin(tp),end(tp));
for(int jp=0;jp<n;jp++)
{
for(int l=-SQ;l<=SQ;l++)
{
if((jp+l)>=0 and (jp+l)<n)
{
int i=tp[jp].second;
int j=tp[jp+l].second;
ll dist=(r[i]+r[j])*(r[i]+r[j]);
ll dp=( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
if(dp<=dist)
{
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
}
for(int i=0;i<n;i++)
{
tp[i].first=y[i];
tp[i].second=i;
}
sort(begin(tp),end(tp));
for(int jp=0;jp<n;jp++)
{
for(int l=-SQ;l<=SQ;l++)
{
if((jp+l)>=0 and (jp+l)<n)
{
int i=tp[jp].second;
int j=tp[jp+l].second;
ll dist=(r[i]+r[j])*(r[i]+r[j]);
ll dp=( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
if(dp<=dist)
{
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
}
set<pair<int,int>> rem;
for(int i=0;i<n;i++)
rem.insert({-r[i],i});
while(rem.size())
{
auto p=*begin(rem);
rem.erase(begin(rem));
if(who[p.second]!=0)
continue;
for(auto op:adj[p.second])
if(who[op]==0)
who[op]=p.second+1;
}
for(int i=0;i<n;i++)
{
cout<<who[i]<<' ';
}
cout<<'\n';
}
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
3 ms |
7512 KB |
Output is correct |
3 |
Correct |
2 ms |
7512 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7772 KB |
Output is correct |
7 |
Correct |
3 ms |
7772 KB |
Output is correct |
8 |
Correct |
3 ms |
7772 KB |
Output is correct |
9 |
Correct |
2 ms |
7772 KB |
Output is correct |
10 |
Correct |
2 ms |
7716 KB |
Output is correct |
11 |
Correct |
2 ms |
7516 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
3 ms |
7516 KB |
Output is correct |
15 |
Correct |
2 ms |
7512 KB |
Output is correct |
16 |
Incorrect |
16 ms |
18268 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2243 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
510 ms |
20568 KB |
Output is correct |
3 |
Correct |
1938 ms |
47112 KB |
Output is correct |
4 |
Correct |
2121 ms |
55052 KB |
Output is correct |
5 |
Correct |
1970 ms |
57864 KB |
Output is correct |
6 |
Correct |
1000 ms |
35952 KB |
Output is correct |
7 |
Correct |
463 ms |
22356 KB |
Output is correct |
8 |
Correct |
78 ms |
10680 KB |
Output is correct |
9 |
Correct |
2151 ms |
55712 KB |
Output is correct |
10 |
Correct |
2093 ms |
62468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1558 ms |
46996 KB |
Output is correct |
2 |
Correct |
1553 ms |
54136 KB |
Output is correct |
3 |
Incorrect |
2288 ms |
118752 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
3 ms |
7512 KB |
Output is correct |
3 |
Correct |
2 ms |
7512 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7772 KB |
Output is correct |
7 |
Correct |
3 ms |
7772 KB |
Output is correct |
8 |
Correct |
3 ms |
7772 KB |
Output is correct |
9 |
Correct |
2 ms |
7772 KB |
Output is correct |
10 |
Correct |
2 ms |
7716 KB |
Output is correct |
11 |
Correct |
2 ms |
7516 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
3 ms |
7516 KB |
Output is correct |
15 |
Correct |
2 ms |
7512 KB |
Output is correct |
16 |
Incorrect |
16 ms |
18268 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
3 ms |
7512 KB |
Output is correct |
3 |
Correct |
2 ms |
7512 KB |
Output is correct |
4 |
Correct |
2 ms |
7516 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7772 KB |
Output is correct |
7 |
Correct |
3 ms |
7772 KB |
Output is correct |
8 |
Correct |
3 ms |
7772 KB |
Output is correct |
9 |
Correct |
2 ms |
7772 KB |
Output is correct |
10 |
Correct |
2 ms |
7716 KB |
Output is correct |
11 |
Correct |
2 ms |
7516 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
3 ms |
7516 KB |
Output is correct |
15 |
Correct |
2 ms |
7512 KB |
Output is correct |
16 |
Incorrect |
16 ms |
18268 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |