#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=3e5+10;;
vector<int> adj[N];
ll who[N];
void solve()
{
ll n;
cin>>n;
vector<ll> x(n),y(n),r(n);
set<ll> tp;
for(int i=0;i<n;i++)
{
cin>>x[i]>>y[i]>>r[i];
tp.insert(y[i]);
}
if(tp.size()==1)
{
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> rem,remming;
for(int i=0;i<n;i++)
remming.push({x[i]-r[i],i});
for(int i=0;i<n;i++)
rem.push({-r[i],i});
while(rem.size())
{
auto p=rem.top();
rem.pop();
if(who[p.second]!=0)
continue;
ll val=x[p.second]+r[p.second];
while(remming.size()>0)
{
auto it=remming.top();
if(it.first<=val)
{
remming.pop();
who[it.second]=p.second+1;
}
else
{
break;
}
}
}
}
else
{
for(int i=0;i<n;i++)
{
for(int j=0;j<=i;j++)
{
// ( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) <= (r1+r2)²
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<<endl;
}
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 |
2 ms |
7516 KB |
Output is correct |
3 |
Correct |
2 ms |
7516 KB |
Output is correct |
4 |
Correct |
2 ms |
7512 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7512 KB |
Output is correct |
7 |
Correct |
2 ms |
7516 KB |
Output is correct |
8 |
Correct |
2 ms |
7516 KB |
Output is correct |
9 |
Correct |
2 ms |
7516 KB |
Output is correct |
10 |
Correct |
2 ms |
7516 KB |
Output is correct |
11 |
Correct |
2 ms |
7512 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
2 ms |
7516 KB |
Output is correct |
15 |
Correct |
2 ms |
7516 KB |
Output is correct |
16 |
Correct |
8 ms |
11612 KB |
Output is correct |
17 |
Correct |
8 ms |
11356 KB |
Output is correct |
18 |
Correct |
8 ms |
11868 KB |
Output is correct |
19 |
Correct |
213 ms |
145580 KB |
Output is correct |
20 |
Correct |
207 ms |
143700 KB |
Output is correct |
21 |
Correct |
185 ms |
84908 KB |
Output is correct |
22 |
Correct |
36 ms |
8276 KB |
Output is correct |
23 |
Correct |
33 ms |
8364 KB |
Output is correct |
24 |
Correct |
28 ms |
8340 KB |
Output is correct |
25 |
Correct |
27 ms |
8272 KB |
Output is correct |
26 |
Correct |
27 ms |
8280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
24776 KB |
Output is correct |
2 |
Incorrect |
162 ms |
29868 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7516 KB |
Output is correct |
2 |
Execution timed out |
3074 ms |
16408 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3038 ms |
30412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
2 ms |
7516 KB |
Output is correct |
3 |
Correct |
2 ms |
7516 KB |
Output is correct |
4 |
Correct |
2 ms |
7512 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7512 KB |
Output is correct |
7 |
Correct |
2 ms |
7516 KB |
Output is correct |
8 |
Correct |
2 ms |
7516 KB |
Output is correct |
9 |
Correct |
2 ms |
7516 KB |
Output is correct |
10 |
Correct |
2 ms |
7516 KB |
Output is correct |
11 |
Correct |
2 ms |
7512 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
2 ms |
7516 KB |
Output is correct |
15 |
Correct |
2 ms |
7516 KB |
Output is correct |
16 |
Correct |
8 ms |
11612 KB |
Output is correct |
17 |
Correct |
8 ms |
11356 KB |
Output is correct |
18 |
Correct |
8 ms |
11868 KB |
Output is correct |
19 |
Correct |
213 ms |
145580 KB |
Output is correct |
20 |
Correct |
207 ms |
143700 KB |
Output is correct |
21 |
Correct |
185 ms |
84908 KB |
Output is correct |
22 |
Correct |
36 ms |
8276 KB |
Output is correct |
23 |
Correct |
33 ms |
8364 KB |
Output is correct |
24 |
Correct |
28 ms |
8340 KB |
Output is correct |
25 |
Correct |
27 ms |
8272 KB |
Output is correct |
26 |
Correct |
27 ms |
8280 KB |
Output is correct |
27 |
Correct |
838 ms |
378500 KB |
Output is correct |
28 |
Correct |
937 ms |
504604 KB |
Output is correct |
29 |
Correct |
890 ms |
481352 KB |
Output is correct |
30 |
Correct |
98 ms |
9408 KB |
Output is correct |
31 |
Correct |
100 ms |
9456 KB |
Output is correct |
32 |
Correct |
98 ms |
9296 KB |
Output is correct |
33 |
Runtime error |
2443 ms |
1048576 KB |
Execution killed with signal 9 |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
7512 KB |
Output is correct |
2 |
Correct |
2 ms |
7516 KB |
Output is correct |
3 |
Correct |
2 ms |
7516 KB |
Output is correct |
4 |
Correct |
2 ms |
7512 KB |
Output is correct |
5 |
Correct |
2 ms |
7516 KB |
Output is correct |
6 |
Correct |
2 ms |
7512 KB |
Output is correct |
7 |
Correct |
2 ms |
7516 KB |
Output is correct |
8 |
Correct |
2 ms |
7516 KB |
Output is correct |
9 |
Correct |
2 ms |
7516 KB |
Output is correct |
10 |
Correct |
2 ms |
7516 KB |
Output is correct |
11 |
Correct |
2 ms |
7512 KB |
Output is correct |
12 |
Correct |
2 ms |
7516 KB |
Output is correct |
13 |
Correct |
2 ms |
7516 KB |
Output is correct |
14 |
Correct |
2 ms |
7516 KB |
Output is correct |
15 |
Correct |
2 ms |
7516 KB |
Output is correct |
16 |
Correct |
8 ms |
11612 KB |
Output is correct |
17 |
Correct |
8 ms |
11356 KB |
Output is correct |
18 |
Correct |
8 ms |
11868 KB |
Output is correct |
19 |
Correct |
213 ms |
145580 KB |
Output is correct |
20 |
Correct |
207 ms |
143700 KB |
Output is correct |
21 |
Correct |
185 ms |
84908 KB |
Output is correct |
22 |
Correct |
36 ms |
8276 KB |
Output is correct |
23 |
Correct |
33 ms |
8364 KB |
Output is correct |
24 |
Correct |
28 ms |
8340 KB |
Output is correct |
25 |
Correct |
27 ms |
8272 KB |
Output is correct |
26 |
Correct |
27 ms |
8280 KB |
Output is correct |
27 |
Correct |
157 ms |
24776 KB |
Output is correct |
28 |
Incorrect |
162 ms |
29868 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |