Created
February 19, 2021 02:35
-
-
Save lakshith-403/060f469966e2403b7f93f728b82e99ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define ll long long | |
#define pb push_back | |
#define f first | |
#define s second | |
#define what_is(a) cout << #a << " is " << a << "\n"; | |
#define shit cout << "shit" << "\n"; | |
#define pi pair<int,int> | |
#pragma GCC target("avx2") | |
#pragma GCC optimize("03") | |
#pragma GCC optimize("unroll-loops") | |
using namespace std; | |
inline void io(){ | |
ios_base::sync_with_stdio(false); | |
cin.tie(NULL); | |
cout.tie(NULL); | |
} | |
const int MAX_SIZE = 1e7+10; | |
bool check(pi a,pi b){ | |
double dis = (long double)(a.f-b.f)*(long double)(a.f-b.f) + (long double)(a.s-b.s)*(long double)(a.s-b.s); | |
return sqrt(dis) <= 10000.0; | |
} | |
bool vis[MAX_SIZE]; | |
void solve(){ | |
vector<int> ans; | |
int Count = 0; | |
int n; | |
cin >> n; | |
vector<pi> vec; | |
for(int i=0;i<n;i++){ | |
int x,y; | |
cin >> x >> y; | |
vec.pb({x,y}); | |
} | |
sort(vec.begin(),vec.end()); | |
for(int i=0;i<n;i++){ | |
Count = 1; | |
if(vis[i])continue; | |
vis[i]=true; | |
for(int j=0;j<n;j++){ | |
if(i==j)continue; | |
if(vec[j].f-vec[i].f>10000)break; | |
if(check(vec[i],vec[j])){ | |
vis[j]=true; | |
Count++; | |
} | |
} | |
ans.pb(Count); | |
} | |
sort(ans.begin(),ans.end()); | |
cout << ans.size() << "\n"; | |
for(int i = 0; i<ans.size()-1;i++) | |
cout << ans[i] << " "; | |
cout << ans[ans.size()-1] << "\n"; | |
} | |
int main(){ | |
io(); | |
solve(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment