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

wa啊郁闷啊,谁帮忙看一下

Posted by MCSE at 2006-11-20 20:31:43 on Problem 1363
#include<iostream.h>
#include<stack>
using namespace std;
int yn(int *r,int n)
{   
	int k,j;
	stack<int> s;
	s.push(-1);
	for(j=1;j<r[0];j++)
       s.push(j);
	for(k=1;k<n;k++)
	{   
		if(s.top()>r[k])  { cout<<"No\n";   break;}
		else if(s.top()==r[k])  { s.pop();   continue;}
		else if(s.top()<r[k])   { s.push(r[k]); continue;}
	}
	if(k>=n) cout<<"Yes\n";
	return 0;
}
		
int main()
{ 
  int num;
  while(cin>>num)
  {   
	  int i;
	  int *rail=new int[num];
	  cin>>rail[0];
	  while(rail[0]!=0)
	  {
	      for(i=1;i<num;i++)
	        cin>>rail[i];
	      yn(rail,num);//function
		  cin>>rail[0];
	  }
	  delete []rail;
	  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