This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#define str string
#define append push_back
#define vector deque
#define vi vector<int>
#define int long long
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define endl '\n'
#define all(ls) ls.begin(),ls.end()
#define sorted(ls) sort(ls.begin(),ls.end());
#define reversed(ls) reverse(ls.begin(),ls.end());
#define print(n) for(auto i:n)cout<<i<<' ';cout<<endl;
#define input(n,ls,m) deque<n>ls(m);for(int i=0;i<m;i++)cin>>ls[i];
#define len(s) s.size()
#define ff first
#define ss second
#define N (int const) 1e5+1
#define pii pair<int,int>
#define SQ(x) ((x)*(x))
#define float double
int mod=1e9+7;
int mod1=998244353;
int sum_(vector<int>ls){int s=0;for(auto i:ls){s+=i;}return s;}
int min(int a,int b){if (a>b){return b;}return a;}
int max(int a,int b){if (a<b){return b;}return a;}
//......................................tHe ReaL cOdE beGinS HerE....................................../
void solve(){
int n;
cin>>n;
vector<int>plane[n+1];
bool mp[n+1];
for(int i=0;i<n;i++){
input(int,a,3);
mp[i]=0;
a={a[2],n-i,a[0],a[1]};
plane[i]=a;
}
sort(plane,plane+n-1);
reverse(plane,plane+n-1);
vi ans(n,0);
for(int i=0;i<n;i++)
ans[i]=i;
for(int i=0;i<n;i++)
plane[i][1]=n-plane[i][1];
for(auto i:plane){
if(mp[i[1]]) continue;
mp[i[1]]=1;
for(auto j:plane){
if(i[1]==j[1] or mp[j[1]]){continue;}
if(sqrtl(SQ(j[2]-i[2])+SQ(j[3]-i[3]))<=j[0]+i[0]){
mp[j[1]]=1;
ans[j[1]]=i[1];
}
}
}
for(auto i:ans){
cout<<i+1<<' ';
}
cout<<endl;
}
signed main(){
int t=1;
// cin>>t;
while(t--){
solve();
}
}
# | 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... |