Created
September 23, 2014 09:02
-
-
Save haroldxin/2400571f21d7683e8110 to your computer and use it in GitHub Desktop.
Circle
This file contains hidden or 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
//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