Advertisement
FHVirus

Untitled

Nov 28th, 2020
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.14 KB | None | 0 0
  1. //{{{
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. //types
  5. typedef long long ll;
  6. typedef pair<int,int> pii;
  7. //input
  8. bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
  9. bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
  10. bool RI(){return true;}
  11. template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
  12. //output
  13. void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
  14. void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
  15. void PL(){puts("");}
  16. template<typename I,typename... T>void PL(const I _x,const T... _tail)
  17. {SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
  18. //macro
  19. #define SZ(x) ((int)(x).size())
  20. #define ALL(x) (x).begin(),(x).end()
  21. #define REP(i,n) for(int i=0;i<int(n);i++)
  22. #define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
  23. #define PER1(i,a,b) for(int i=(a);i>=int(b);i--)
  24. #define pb push_back
  25. #define mkp make_pair
  26. #define F first
  27. #define S second
  28. //debug
  29. #ifdef darry140
  30. template<typename A,typename B>
  31. ostream& operator <<(ostream&_s, const pair<A,B> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
  32. template<typename It>
  33. ostream& _OUTC(ostream &_s,It _b,It _e)//container
  34. {
  35.     _s<<"{";
  36.     for(auto _it=_b;_it!=_e;_it++) _s<<(_it==_b?"":" ")<<*_it;
  37.     _s<<"}";
  38.     return _s;
  39. }
  40. template<typename A,typename B>
  41. ostream& operator <<(ostream&_s, const map<A,B> &_c){return _OUTC(_s,ALL(_c));}
  42. template<typename T>
  43. ostream& operator <<(ostream&_s, const set<T> &_c){return _OUTC(_s,ALL(_c));}
  44. template<typename T>
  45. ostream& operator <<(ostream&_s, const vector<T> &_c){return _OUTC(_s,ALL(_c));}
  46. template<typename I>
  47. void _DOING(const char *_s,I&& _x){cerr<<_s<<"="<<_x<<endl;}//without ','
  48. template<typename I,typename... T>
  49. void _DOING(const char *_s,I&& _x,T&&... _tail)//with ','
  50. {
  51.     int _c=0;
  52.     static const char _bra[]="({[";
  53.     static const char _ket[]=")}]";
  54.     while(*_s!=',' || _c!=0)//eg. mkp(a,b)
  55.     {
  56.         if(strchr(_bra,*_s)) _c++;
  57.         if(strchr(_ket,*_s)) _c--;
  58.         cerr<<*_s++;
  59.     }
  60.     cerr<<"="<<_x<<", ";
  61.     _DOING(_s+1,_tail...);
  62. }
  63. #define debug(...) do{\
  64.     fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
  65.     _DOING(#__VA_ARGS__,__VA_ARGS__);\
  66. }while(0)
  67. #else
  68. #define debug(...)
  69. #endif
  70. //}}}
  71. const int maxn=5e5+5;
  72. ll x[maxn],y[maxn],r[maxn];
  73. int n;
  74. void read()
  75. {
  76.     scanf("%d",&n);
  77.     for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&x[i],&y[i],&r[i]);
  78. }
  79. bool inter(int i,int j)
  80. {
  81.     ll dx=x[i]-x[j],dy=y[i]-y[j];
  82.     ll dd=dx*dx+dy*dy,rr=(r[i]+r[j])*(r[i]+r[j]);
  83.     return dd<=rr;
  84. }
  85. void build(){}
  86. int ans[maxn];
  87. void sol()
  88. {
  89.     vector<int> cir(n);iota(ALL(cir),1);
  90.     while(SZ(cir))
  91.     {
  92.         int i=cir[0];
  93.         for(int j:cir) if(tie(r[j],i)>tie(r[i],j))
  94.             i=j;
  95.  
  96.         vector<int> nxt;
  97.         for(int j:cir)
  98.         {
  99.             if(!inter(i,j)) nxt.pb(j);
  100.             else ans[j]=i;
  101.         }
  102.         nxt.swap(cir);
  103.     }
  104.     REP1(i,1,n) printf("%d%c",ans[i]," \n"[i==n]);
  105. }
  106. int main()
  107. {
  108.     read();
  109.     build();
  110.     sol();
  111.     return 0;
  112. }
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement