Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why wrong 求测试数据,谢谢!

Posted by ningbohezhijun at 2008-12-07 17:42:17 on Problem 1161 and last updated at 2008-12-07 17:42:37
求测试数据,谢谢!
#include<stdio.h>
int main()
{
	int M,N,L,t[31],a[251][251],i,j,k,d[201][201],n,k1,b[250],s,smin,min,c[30][200];
	scanf("%d",&M);
	scanf("%d",&N);
    scanf("%d",&L);
	for(i=1;i<=L;i++)
		scanf("%d",&t[i]);
	for(i=1;i<=N;i++)
		for(j=1;j<=N;j++)
			a[i][j]=0;
	for(i=1;i<=M;i++)
		for(j=1;j<=M;j++)
			d[i][j]=32767;
		for(i=1;i<=M;i++)
			d[i][i]=0;
	for(i=1;i<=L;i++)
		for(j=1;j<=N;j++)
			c[i][j]=0;
	for(k=1;k<=M;k++)
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
			scanf("%d",&b[i]);
		for(i=0;i<n-1;i++)
		{
			if(a[b[i+1]][b[i]])
				d[a[b[i+1]][b[i]]][k]=d[k][a[b[i+1]][b[i]]]=1;
			a[b[i]][b[i+1]]=k;
		}
		if(a[b[0]][b[n-1]])
			d[a[b[0]][b[n-1]]][k]=d[k][a[b[0]][b[n-1]]]=1;
		a[b[n-1]][b[0]]=k;
	}
	for(k1=1;k1<=M;k1++)
		for(i=1;i<=M;i++)
			for(j=1;j<=M;j++)
				if(i!=j&&(d[i][j]>d[i][k1]+d[k1][j]))
					d[i][j]=d[i][k1]+d[k1][j];
	for(i=1;i<=L;i++)
	{
		k=1;
		for(j=1;j<=N;j++)
			if(a[t[i]][j])
			{
				c[i][k++]=a[t[i]][j];
				c[i][k++]=a[j][t[i]];
			}
			
	}
	smin=32767;
	for(i=1;i<=M;i++)
	{
		s=0;
		for(j=1;j<=L;j++)
		{
			min=32767;
			k=1;
			while(c[j][k])
			{
				if(min>d[i][c[j][k]])
					min=d[i][c[j][k]];
				k++;
			}
			s+=min;
		}
		if(s<smin)
			smin=s;
	}
	printf("%d\n",smin);
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator