比赛 20101118 评测结果 WEETETTEEW
题目名称 扩散 最终得分 0
用户昵称 wangwangdog 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2010-11-18 11:06:20
显示代码纯文本
#include<stdio.h>
FILE *fin,*fout;
long x[10],y[10],n,step,find,i,j,k;
struct aaa
{
	long dian[10],all;
}flag[500][500];
int main()
{
	fin=fopen("ppg.in","rb");
	fout=fopen("ppg.out","wb");
    fscanf(fin,"%ld\n",&n);
	for(i=1;i<=n;i++)
	{
		fscanf(fin,"%ld%ld\n",&x[i],&y[i]);
		x[i]=x[i]+100;
		y[i]=y[i]+100;
	}
	for(i=0;i<=499;i++)
		for(j=0;j<=499;j++)
		{
			for(k=1;k<=n;k++)
			{
			flag[i][j].dian[k]=0;
			flag[i][j].all=n;
			}
		}
	find=0;
	step=0;
	while(find==0)
	{
		step++;
		for(i=1;i<=n;i++)
		{
			for(j=x[i]-step+1;j<=x[i]+step-1;j++)
				for(k=y[i]-step+1;k<=y[i]+step-1;k++)
				{
					if(flag[j][k].dian[i]==0)
					{
						flag[j][k].dian[i]=1;
						flag[j][k].all--;
						if(flag[j][k].all==0)find=1;
					}
				}
			long xx=x[i];
			long yy=y[i];
			if(flag[xx-step][yy].dian[i]==0)
			{
			    flag[xx-step][yy].dian[i]=1;
				flag[xx-step][yy].all--;
				if(flag[xx-step][yy].all==0)find=1;
			}
			if(flag[xx+step][yy].dian[i]==0)
			{
			    flag[xx+step][yy].dian[i]=1;
				flag[xx+step][yy].all--;
				if(flag[xx+step][yy].all==0)find=1;
			}
			if(flag[xx][yy+step].dian[i]==0)
			{
			    flag[xx][yy+step].dian[i]=1;
				flag[xx][yy+step].all--;
				if(flag[xx][yy+step].all==0)find=1;
			}
			if(flag[xx][yy-step].dian[i]==0)
			{
			    flag[xx][yy-step].dian[i]=1;
				flag[xx][yy-step].all--;
				if(flag[xx][yy-step].all==0)find=1;
			}
		}
	}
	fprintf(fout,"%ld",step+1);
	fclose(fin);
	fclose(fout);
	return 0;
}