记录编号 118288 评测结果 AAAAAAAAAA
题目名称 [USACO Mar08] 混乱的齿轮 最终得分 100
用户昵称 GravatarHouJikan 是否通过 通过
代码语言 C++ 运行时间 0.014 s
提交时间 2014-09-05 22:21:46 内存使用 0.33 MiB
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <iterator>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint; 
const int INF=0x7ffffff;
const double EPS=1e-6;
//==============struct declaration==============
struct roundss
{
  int x,y,r,no;
  roundss(){;}
  roundss(int x,int y,int r):x(x),y(y),r(r){}
}rounds[1060];
//==============var declaration=================
bool vis[1060];
int n;
//==============function declaration============
bool con(roundss i,roundss j);
double addspeed(int x);
//==============main code=======================
int main()
{  
  string FileName="rollers";//程序名 
  string FloderName="COGS";//文件夹名 
  freopen((FileName+".in").c_str(),"r",stdin);
  freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG  
  system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
  clock_t Start_Time=clock();
#endif   
  int sn;
  cin>>n;
  For(i,1,n)
  {
    scanf("%d%d%d",&rounds[i].x,&rounds[i].y,&rounds[i].r);
    rounds[i].no=i;
    if (!rounds[i].x&&!rounds[i].y)
      sn=i;  
  }
  memset(vis,0,sizeof(vis));
  queue <roundss> Q;
  Q.push(rounds[sn]);
  int en;
  while (!Q.empty())
  {
    roundss now=Q.front();Q.pop(); 
    vis[now.no]=true;
    for(int i=1;i<=n;i++)
      if (!vis[i]&&con(rounds[i],now))
        Q.push(rounds[i]);
    if (Q.empty())
    {
      printf("%d %d\n",now.x,now.y);
      return 0;
    }
  }
#ifdef DEBUG
  clock_t End_Time=clock();
  printf("\n\nTime Used : %.0lf ms\n",(End_Time-Start_Time)/CLOCKS_PER_SEC*1000);
#endif  
  return 0;
}
//================fuction code====================
bool con(roundss i,roundss j)
{
  double xx=i.x-j.x;
  double yy=i.y-j.y;
  double dist=xx*xx+yy*yy;
  double dr=i.r+j.r;
  if (fabs(dist-dr*dr)<=EPS)
    return true;
  return false;
}