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

aaaaaaaaaaaa,加强版的数据都过了,还是不行啊

Posted by cqlf at 2011-11-29 17:35:38 on Problem 1363
#include <iostream>
#include <stack>
#include <cstdio>
using namespace std;
int main()
{
	int N;
	stack<int > pp;
	int i,j,k,flag,top;
	int a[1005];
	while(~scanf("%d",&N))
	{
		if(N==0) break;
		while(~scanf("%d",&a[1]))
		{
			flag=0;
			if(a[1]==0) break;
			for(i=2;i<=N;i++)
				cin>>a[i];
			i=1;
			pp.push (i);
			while(!pp.empty ())
			{
				for(j=2;j<=N;j++)
				{
					top=pp.top ();
					while(top==a[i]) 
					{
						pp.pop ();
						if(!pp.empty ())
						top=pp.top();
						i++;
					}
					pp.push(j);
				}
				while(top==a[i]) pp.pop (); 
				while(1)
				{
					top=pp.top ();
					if(a[i]!=top) {flag=1;break;}
					else 
					{
						pp.pop();
						i++;
					}
					if(i==N+1) break;
				}
				break;
			}
			if(flag==0) printf("Yes\n");
			else printf("No\n");
		}
		printf("\n");
	}
	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