比赛 顾研NOIP2011模拟赛 评测结果 AAAAATTTTT
题目名称 超空间电台 最终得分 50
用户昵称 苏轼 运行时间 5.329 s
代码语言 C++ 内存使用 5.11 MiB
提交时间 2012-10-17 21:11:59
显示代码纯文本
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<cmath>
using namespace std;
int n,answer=0;
double answ=99999999;
struct hehe
{
	int flag;
	double xx,yy,zz;
}w[505];
double ww[505][505]={0};
set<double>q;
int main()
{
	freopen ("hyper.in","r",stdin);
	freopen ("hyper.out","w",stdout);
	//^.^
	cin>>n;
	//=.=
	for (int i=1;i<=n;i++)
	{
		cin>>w[i].xx>>w[i].yy>>w[i].zz>>w[i].flag;
	}
	//-.-
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (i==j)
				continue;
			double xxx,yyy,zzz;
			xxx=w[i].xx-w[j].xx;
			yyy=w[i].yy-w[j].yy;
			zzz=w[i].zz-w[j].zz;
			q.insert(xxx*xxx+yyy*yyy+zzz*zzz);
			ww[i][j]=xxx*xxx+yyy*yyy+zzz*zzz;
		}
	}
	//+.+ 
	set<double>::iterator it;
	for (it=q.begin();it!=q.end();it++)
	{
		int ans=0;
		for (int i=1;i<=n;i++)
		{
			int a=1,b=0;
			for (int j=1;j<=n;j++)
			{
				if (i==j)
					continue;
				if (ww[i][j]<=*it)
				{
					if (w[i].flag!=w[j].flag)
						b++;
					else
						a++;
				}
			}
			if (a<b)
				ans++;
		}
		if (ans!=0&&answer==ans&&*it<answ)
		{
			answ=*it;
		}
		if (answer<ans)
		{
			answ=*it;
			answer=ans;
		}
	}
	if (answ==99999999)
		answ=0;
	printf("%d\n%.4lf",answer,sqrt(answ));
	//*.* #.# ~.~
}