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

Poj 1363 Rails

2010-09-10 10:13 519 查看
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
const int maxn=1005;
stack <int> S;
int x[maxn];
int main()
{
int n,y,i,j;
bool yes;
while (scanf("%d",&n)&&n){
while (scanf("%d",&x[0])&&x[0]){
for (i=1;i<n;i++)
scanf("%d",&x[i]);
while (!S.empty())
S.pop();
yes=1;
j=1;
for (i=0;yes&&i<n;i++){
while (j<=x[i]){
S.push(j);
j++;
}
y=S.top();
S.pop();
if (x[i]!=y)
yes=0;
}
printf("%s/n",yes?"Yes":"No");
}
printf("/n");
}
return 0;
}
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  rails ini