比赛 不平凡的世界 评测结果 WWWWWWTTTT
题目名称 不平凡的引线 最终得分 0
用户昵称 Tabing010102 运行时间 4.036 s
代码语言 C++ 内存使用 1.65 MiB
提交时间 2015-11-05 10:27:10
显示代码纯文本
using namespace std;
#include<iostream>
#include<fstream>

#define cin fin
#define cout fout

ifstream fin("firelead.in");
ofstream fout("firelead.out");

struct yinxian
{
	long start;
	long end;
	int length;
};

void input(void);
bool JudgeOneIsJieDian(yinxian,long);
void JudgeAllIsJieDian(void);
void CalculateJieDianNum(void);
void output(void);

long num;
yinxian data[100010];
bool IsJieDian_start[100010];
bool IsJieDian_end[100010];
long JieDianNum=0;

int main()
{
	input();
	JudgeAllIsJieDian();
	CalculateJieDianNum();
	output();
	return 0;
}

void input()
{
	cin>>num;
	for(long i=1;i<=num;i++)
		cin>>data[i].start>>data[i].end>>data[i].length;
}

bool JudgeOneIsJieDian(long temp,long pos)
{
	bool judge=true;
	for(long i=1;i<=num && judge;i++)
	{
		while(pos!=i)
		{
			if(temp==data[i].start) judge=false;
			if(temp==data[i].end) judge=false;
			break;
		}
	}
	return judge;
}

void JudgeAllIsJieDian()
{
	for(long i=1;i<=num;i++)
	{
		IsJieDian_start[i]=JudgeOneIsJieDian(data[i].start,i);
		IsJieDian_end[i]=JudgeOneIsJieDian(data[i].end,i);
	}
}

void CalculateJieDianNum()
{
	for(long i=0;i<=num;i++)
	{
		if(IsJieDian_start[i]==true) JieDianNum++;
		if(IsJieDian_end[i]==true) JieDianNum++;
	}
}

void output()
{
	double result=(double)JieDianNum/(double)num;
	cout<<(double)result;
//	for(long i=1;i<=num;i++) cout<<endl<<IsJieDian_start[i]<<' '<<IsJieDian_end[i];
}