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 sunmoonstar_love at 2005-07-17 17:42:34 on Problem 2491
In Reply To:能帮我侃侃我错在那吗 Posted by:tashj at 2005-07-17 17:35:45
> #include<iostream>
> #include<string>
> using namespace std;
> struct node
> {
>     char from[1000],to[1000];
> }rode[335];
> int main()
> {
> 	int num,i,j,n,record[335],k,m;
> 	cin>>n;
> 	for(i=1;i<=n;i++)
> 	{
> 	
> 		cin>>num;
> 		for(j=1;j<=num-1;j++)
> 		  cin>>rode[j].from>>rode[j].to;
> 			cout<<"Scenario #"<<i<<":"<<endl;
> 		memset(record,0,sizeof(record[0])*(num+1));
> 		for(j=1;j<num;j++)
> 		{
> 			for(k=j+1;k<=num;k++)
> 			{
> 				if(strcmp(rode[j].from,rode[k].to)==0)
> 				{
> 					record[j]=k;
> 				}
> 			    else if(strcmp(rode[j].to,rode[k].from)==0)
> 				{
> 					record[k]=j;
> 				}
> 			}
> 		}
> 		for(j=1;j<=num;j++)
> 			if(record[j]==0)
> 			{
>               m=j;
> 			  break;
> 			}
> 			cout<<rode[m].from<<endl;
> 			cout<<rode[m].to<<endl;
> 		for(j=1;j<=num;j++)
> 		{
> 		
> 		    for(k=1;k<=num;k++)
> 			{
> 				if(record[k]==m)
> 				{
> 					cout<<rode[k].to<<endl;
> 					m=k;
> 					break;
> 				}
> 			}
> 		}
> 		cout<<endl;
> 	}
> 	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