Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- created: 2022-06-12-14.38.54
- ***/
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- template<typename U> using ordered_set=tree<U, null_type,less<U>,rb_tree_tag,tree_order_statistics_node_update>;
- #define ll long long
- #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
- #define get_lost_idiot return 0
- #define nl '\n'
- ll mx=0;
- vector<ll>parent(200005),rankk(200005);
- void make_set(ll n)
- {
- for(ll i=0; i<n; i++)
- {
- parent[i] = i;
- rankk[i] = 1;
- }
- }
- ll find_set(ll v)
- {
- if (v == parent[v])
- {
- return v;
- }
- return parent[v] = find_set(parent[v]);
- }
- void union_sets(ll a, ll b)
- {
- a = find_set(a);
- b = find_set(b);
- if (a == b) return;
- parent[b]=a;
- rankk[a]+=rankk[b];
- rankk[b]=0;
- }
- double distnc(double x,double y,double x1,double y1)
- {
- return (x-x1)*(x-x1)+(y-y1)*(y-y1);
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- ll n;
- while(cin>>n && n!=-1)
- {
- parent.resize(n);
- rankk.resize(n);
- make_set(n);
- double x[n+4],y[n+4],r[n+4];
- ll m,i,j,k,l;
- for(i=0;i<n;i++)
- {
- cin>>x[i]>>y[i]>>r[i];
- for(j=0;j<i;j++)
- {
- double diss=distnc(x[i],y[i],x[j],y[j]);
- if((diss-(1e-8))<=((r[i]+r[j])*(r[i]+r[j])))
- {
- if((diss+(1e-8))>=((r[i]-r[j])*(r[i]-r[j])))
- {
- union_sets(i,j);
- }
- }
- }
- }
- m=0;
- if(rankk.empty()==false) m=*max_element(rankk.begin(),rankk.end());
- cout<<"The largest component contains "<<m<<" ring";
- if(m!=1) cout<<"s";
- cout<<"."<<nl;
- }
- get_lost_idiot;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement