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

我是一个新手,大家帮帮忙看看怎么改啊!!!兄弟我在这里感激不尽!!!!!!!谢谢了……

Posted by 457 at 2009-03-26 23:57:27 on Problem 2263
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char str1[19901][33],str2[19901][33],start[33],end[33];
int num[19901],shu[19901],sign[19901];
int n,r,min,k,flag;
int dfs(char str[33],char ends[33])
{
	int i,j;
	int max=100000;
	if(strcmp(str,ends)==0)
	{
		for(j=0;j<k;j++)
		if(max>shu[j])
		max=shu[j];	
		if(max>min)
		min=max;
		return 0;
	}
	for(i=0;i<r;i++)
	{
		if(strcmp(str1[i],str)==0&&!sign[i])
		{
			sign[i]=1;
			shu[k]=num[i];	
			k++;
			dfs(str2[i],ends);
			k--;
			sign[i]=0;
		}	
	}
}
int main()
{
	int i,j;
	int g=0;
	while(scanf("%d%d",&n,&r)!=EOF)
	{
		g++;
		if(n==0&&r==0)
		break;
		for(i=0;i<r;i++)
		scanf("%s%s%d",str1[i],str2[i],&num[i]);
		scanf("%s%s",start,end);
		min=0;
		memset(shu,0,sizeof(shu));
		for(i=0;i<r;i++)
		{
			memset(sign,0,sizeof(sign));
			if(strcmp(start,str1[i])==0)
			{
				dfs(start,end);
			}
			else if(strcmp(end,str1[i])==0)
			{
				dfs(end,start);
			}
		}
		printf("Scenario #%d\n",g);
		printf("%d tons\n",min);
		printf("\n");
	}
}

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