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

Re:代码很短觉得情况都考虑到了可还是WA,谁帮忙看看啊!!!

Posted by 0761 at 2005-09-21 23:53:59 on Problem 1363
In Reply To:代码很段觉得情况都考虑到了可还是WA,谁帮忙看看啊!!! Posted by:0761 at 2005-09-21 23:53:45
> #include<iostream>
> #include<stack>
> using namespace std;
> void main()
> {
> 	stack<int> coach,station;       //coach????????????????????station????????
> 	int a[1000],n,nn;
> 	cin>>n;
> 	nn=n;
> 	while(n!=0){
> 		cin>>a[0];
> 		while(a[0]!=0){
> 			for(int i=1;i<n;i++)
> 				cin>>a[i];
> 			for(int j=0;j<n;j++)                     //????????????????coach??
> 				coach.push(a[j]);
> 			while(n>0){
> 				if((!coach.empty())&&coach.top()==n){ //coach????????????????????????????????
> 					coach.pop();                      //????????????n-1
> 					n--;
> 					continue;
> 				}
> 				else if((!station.empty())&&station.top()==n){//station????????????????????????????
> 					station.pop();                       //????????????????n-1
> 					n--;
> 					continue;
> 				}
> 				else if((!coach.empty())&&coach.top()!=n){ //coach????????????????????????
> 					station.push(coach.top());        //??????????station????????coach????????
> 					coach.pop();
> 				}
> 				else if(coach.empty()&&(!station.empty())&&station.top()!=n){  //coach????????station??????????????????
> 					cout<<"No"<<endl;                 //t??????1????????
> 					n=-1;                             //n??-1??????while????
> 				}
> 			}
> 			if(n==0)
> 				cout<<"Yes"<<endl;
> 			n=nn;
> 			cin>>a[0];
> 			if(a[0]==0){ 
> 				while(station.empty()==false)
> 					station.pop();
> 				while(coach.empty()==false)
> 					coach.pop();
> 			}
> 		}
> 		cin>>n;
> 		cout<<endl;
> 		nn=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