zoj 1259,例子过了,wa,程序有注释哦~Rails--------------------------------------------------------------------------------Time Limit:1 Second Memory Limit:32768 KB -------------------------------------------------------------------------------
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 01:30:49
zoj 1259,例子过了,wa,程序有注释哦~Rails--------------------------------------------------------------------------------Time Limit:1 Second Memory Limit:32768 KB -------------------------------------------------------------------------------
zoj 1259,例子过了,wa,程序有注释哦~
Rails
--------------------------------------------------------------------------------
Time Limit:1 Second Memory Limit:32768 KB
--------------------------------------------------------------------------------
There is a famous railway station in PopPush City.Country there is incredibly hilly.The station was built in last century.Unfortunately,funds were extremely limited that time.It was possible to establish only a surface track.Moreover,it turned out that the station could be only a dead-end one (see picture) and due to lack of available space it could have only one track.
The local tradition is that every train arriving from the direction A continues in the direction B with coaches reorganized in some way.Assume that the train arriving from the direction A has N
zoj 1259,例子过了,wa,程序有注释哦~Rails--------------------------------------------------------------------------------Time Limit:1 Second Memory Limit:32768 KB -------------------------------------------------------------------------------
#include
#include
#include
using namespace std;
int b[1100];//数组用来存输入的序列
int main()
{
stack a;//保存序列的栈
stack xb;//序列中元素对应的下标的栈
int n,i,p,x;
while(scanf("%d",&n)!=EOF&&n)//序列的个数
{
while(scanf("%d",&b[0])!=EOF&&b[0])//序列的第一个数不为0就继续
{
while(!a.empty())//把栈清空
{
a.pop();
}
while(!xb.empty())//把栈清空
{
xb.pop();
}
p=1;//用来判断序列是否能变成1 2 3 ···n,假设能,p=1,不能,p=0
for(i=1;i=0;i--)//从序列的后面往前来
{
while(!a.empty()&&b[i]