您的位置:首页 > 大数据 > 人工智能

Rails

2013-03-24 23:19 99 查看
http://poj.org/problem?id=1363

View Code

#include<iostream>
#include<stack>
using namespace std ;
int main()
{
int a[1005] ;
int n ;
while(cin>>n,n!=0)
{
while(cin>>a[0],a[0])
{
for(int i=1; i<n; i++)
cin>>a[i] ;
stack<int>s ;
int num = 0 ;
for(int i=1; i<=n; i++)
{
s.push(i) ;
while(!s.empty()&&s.top()==a[num])
{
s.pop() ;
num++ ;
}
}
if(s.empty())
cout<<"Yes"<<endl ;
else
cout<<"No"<<endl ;
}
cout<<endl ;
}
return 0 ;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: