| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
感觉没问题,但总是WA#include<iostream>
#include<stack>
using namespace std;
int main()
{
stack<int> s;
int n,in,out[1001],i,j,k,flag,max;
while((cin>>n)&&n!=0)
{
while(1)
{
cin>>out[1];
if (out[1]==0)
{
cout<<endl;
break;
}
for (i=2;i<=n;i++) cin>>out[i];
in=1;
max=1;
s.push(0);
while(1)
{
if (out[in]>s.top())
{
for (i=max;i<out[in];i++) s.push(i);
if (max<out[in]) max=out[in]+1;
in++;
}
else if (out[in]==s.top())
{
s.pop();
in++;
}
else if (out[in]<s.top())
{
cout<<"No"<<endl;
break;
}
if (in>n)
{
cout<<"Yes"<<endl;
break;
}
}
}
while(!s.empty()) s.pop();
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator