Skip to content

Instantly share code, notes, and snippets.

@haroldxin
Created September 23, 2014 09:02
Show Gist options
  • Save haroldxin/2400571f21d7683e8110 to your computer and use it in GitHub Desktop.
Save haroldxin/2400571f21d7683e8110 to your computer and use it in GitHub Desktop.
Circle
//Unfinshed
#include <iostream>
#include <cstdio>
int n;
const int maxn = 7000;
bool check[maxn+1];
void init() {
for(int i=0,i<=maxn;i++)check[i]=false;
return ;
}
int x[maxn+1],y[maxn+1],r[maxn+1];
int judge();
int dfs(int i);
int main () {
init();
cin >> n;
for(int i=1;i<=n;i++){
cin >> x[i] >> y[i] >> r[i];
}
int a=0;
for(int i=1;i<=n;i++){
if (check[i]==false){
dfs(i);
a++;
}
}
cout << i;
}
int dfs(int i){
check[i]=true;
for(int j=1;j<=n;j++){
if((check[j]==false)&&(judge(i,j))){
dfs(j);
}
}
}
int judge(int i,int j){
int judge;
judge=(((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))<=((r[i]+r[j])*((r[i]+r[j]))));
return judge;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment