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

要疯了。。怎么一直runtime error啊。。。

Posted by 20101646 at 2012-08-18 12:28:48 on Problem 1363
#include <iostream>
using namespace std;
const int MAXN = 100+10;
int n,target[MAXN];

int main()
{
	while (cin>>n && n!= 0)
	{
		while (cin>>target[1] && target[1] != 0)
		{
			int stack[MAXN],top = 0;
			int A = 1,B = 1;
			int ok = 1;

			for (int i = 2;i <= n;i++)
				cin>>target[i];

			while (B <= n)
			{
				if (A == target[B]){A++;B++;}
				else if (top && stack[top] == target[B]){top--;B++;}
				else if (A <= n){stack[++top] = A++;}
				else {ok = 0;break;}
			}
			if (ok == 0)
				cout<<"No"<<endl;
			else
				cout<<"Yes"<<endl;
		}
		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