| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
怎么没人啊 ,自己顶!!!!In Reply To:谁能帮我看看为什么WA,或者提供一下测试数据也行。 Posted by:ACM06021fly at 2006-09-30 11:01:22 > #include<stdio.h>
> #include<math.h>
> #define SIZE 110
>
> struct Circle{
> int x,y,r;
> }circle[SIZE];
> struct Max{
> int lx,rx,uy,dy;
> }max[SIZE];
> bool map[SIZE][SIZE];
> int flag[SIZE],n;
> bool link(int i, int j){
> if(abs(circle[i].x-circle[j].x)<=circle[i].r+circle[j].r && abs(circle[i].y-circle[j].y)<=circle[i].r+circle[j].r)
> return true;
> return false;
> }
> void dfs(int k,int f)
> {
> int i;
> for(i = 0; i < n; i++)
> if(map[k][i] && !flag[i]){
> flag[i] = f;
> dfs(i,f);
> }
> }
> int main()
> {
> int w,h,i,j;
> scanf("%d%d%d",&w,&h,&n);
> for(i = 0; i < n; i++)
> scanf("%d%d%d",&circle[i].x,&circle[i].y,&circle[i].r);
> for(i = 0; i < n; i++){
> for(j = i+1; j < n; j++)
> if(link(i,j))
> map[i][j] = map[j][i] = 1;
> }
> int f = 1,e;
> for(i = 0; i < n; i++){
> if(!flag[i]){
> flag[i] = f;
> dfs(i,f);
> f++;
> }
> }
> for(i = 1; i < f; i++){
> max[i].lx = 1000000;
> max[i].rx = 0;
> max[i].uy = 0;
> max[i].dy = 1000000;
> }
> for(i = 0; i < n; i++){
> e = flag[i];
> if(circle[i].x+circle[i].r > max[e].rx)
> max[e].rx = circle[i].x+circle[i].r;
> if(circle[i].x-circle[i].r < max[e].lx)
> max[e].lx = circle[i].x-circle[i].r;
> if(circle[i].y+circle[i].r > max[e].uy)
> max[e].uy = circle[i].y+circle[i].r;
> if(circle[i].y-circle[i].r < max[e].dy)
> max[e].dy = circle[i].y-circle[i].r;
> }
> int out = w*h;
> for(i = 1; i < f; i++)
> out -= ((max[i].rx-max[i].lx)*(max[i].uy-max[i].dy));
> printf("%d\n",out);
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator