记录编号 |
122357 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[HAOI 2006]聪明的猴子 |
最终得分 |
100 |
用户昵称 |
HouJikan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.061 s |
提交时间 |
2014-09-23 11:29:59 |
内存使用 |
0.33 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <iterator>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <deque>
#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;
using namespace std;
//================struct declaration======================
double sqr(int x){return x*x;}
struct points
{
int x,y;
double dist(const points &rhs) const
{
return sqrt(sqr(x-rhs.x)+sqr(y-rhs.y));
}
};
struct HeapNode
{
int to;
double dist;
HeapNode(int to=0,double dist=0):to(to),dist(dist){}
bool operator <(const HeapNode &rhs) const
{
return dist>rhs.dist;
}
};
//================var declaration=-========================
const int MAXN=1010;
int n,m;
int range[510];
points point[MAXN];
double d[MAXN];
//================function declaration====================
void prim();
//================main code===============================
int main()
{
string ProgrammeName="monkey";
string FloderName="COGS";
freopen((ProgrammeName+".in").c_str(),"r",stdin);
freopen((ProgrammeName+".out").c_str(),"w",stdout);
#ifdef DEBUG
clock_t Start_Time=clock();
system(("copy C:\\Users\\abc\\Desktop\\HouJikan\\"+FloderName+"\\standard.cpp C:\\Users\\abc\\Desktop\\HouJikan\\"+FloderName+"\\submit.txt").c_str());
#endif
scanf("%d",&m);
For(i,1,m)
scanf("%d",range+i);
scanf("%d",&n);
For(i,1,n)
scanf("%d%d",&point[i].x,&point[i].y);
prim();
#ifdef DEBUG
clock_t End_Time=clock();
printf("\n\nTime Used :%.6lf Ms\n",double(Start_Time-End_Time)/(-CLOCKS_PER_SEC));
#endif
return 0;
}
//================function code===========================
void prim()
{
bool in[MAXN];
For(i,1,n)
d[i]=INF,in[i]=false;
d[1]=0;
For(i,1,n)
{
double Min=INF;int minn=-1;
For(i,1,n)
if (!in[i]&&d[i]<Min)
Min=d[i],minn=i;
in[minn]=true;
For(i,1,n)
if (!in[i]&&d[i]>max(d[minn],point[minn].dist(point[i])))
d[i]=max(d[minn],point[minn].dist(point[i]));
}
double Max=0;
For(i,1,n)
Max=max(Max,d[i]);
int cnt=0;
For(i,1,m)
if (Max-range[i]<=eps)
cnt++;
printf("%d\n",cnt);
}