比赛 东方幻想乡 S3 评测结果 AAWWWEEEEEEEEEEEEEEE
题目名称 铃仙•优昙华院•稻叶 最终得分 10
用户昵称 Truth.Cirno 运行时间 1.143 s
代码语言 C++ 内存使用 0.64 MiB
提交时间 2012-08-09 21:28:11
显示代码纯文本
#include <cstdio>
#include <memory.h>
using namespace std;

int total[51],total2[51],waynum[51],way[51][51],que[30000]={1},dad[30000],tnow[30000];
double f[51]={0,100},fn[51];

int main(void)
{
	freopen("reisen.in","r",stdin);
	freopen("reisen.out","w",stdout);
	int i,j,n,m,t,a,b,tim,tail=0,head=0,temphead;
	scanf("%d%d%d",&n,&m,&t);
	for (i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		way[a][waynum[a]++]=b;
	}
	for (tim=0;tim<t;tim++)
	{
		memset(total,0,sizeof(total));
		memset(total2,0,sizeof(total2));
		for (i=tail;i<=head;i++)
		{
			if (tnow[i]==tim)
			{
				temphead=head;
				head++;
				que[head]=que[i];
				dad[head]=dad[tail];
				tnow[head]=tnow[i]+1;
				for (j=0;j<waynum[que[i]];j++)
					if (dad[i]!=way[que[i]][j])
					{
						head++;
						que[head]=way[que[i]][j];
						dad[head]=que[i];
						tnow[head]=tnow[i]+1;
					}
				total[que[i]]+=(head-temphead);
				total2[que[i]]++;
			}
			else
				break;
		}
		tail=i;
		for (i=1;i<=n;i++)
			if (total[i])
			{
				fn[i]=f[i]/total[i];
				f[i]=fn[i]*total2[i];
			}
		for (i=tail;i<=head;i++)
		{
			if (tnow[i]==tim+1)
				f[que[i]]+=fn[dad[i]];
			else
				break;
		}
	}
	for (i=1;i<=n;i++)
		printf("%.3lf\n",f[i]);
	return(0);
}