time limit: 1 sspace limit: 128000 KBtitle level: Golden GoldTitle Description
Description
There is a railway station in the City of Angels, and every train is driven from a to the station,
Then pull out of the station from the B direction.
To dispatch the train, the train station has a parking track, which can hold 5 trains. It is known that the order from a into the station is 1, 2, 3 .... Now give you a scheduling scheme, determine whether it is feasible, if feasible, output outbound order.
There are several scheduling methods:
A. Drive the first car on a to the B direction
B. Stop the first car on a in a suspended orbit
C. Move the outermost car on the suspended track out of the b direction
Enter a description
Input Description
Enter the first line, an integer n (n<30), to indicate the number of scheduling steps.
The next line is a string that has n uppercase letters, indicating the scheduling method.
Output description
Output Description
If the output is not feasible (stop the station full and stop, stop the station empty and then the car), the output line "No".
If feasible, the output line "Yes", and then output a number of lines, each line an integer, indicating the vehicle outbound sequence.
Sample input
Sample Input
[Example input 1]
6
Abbcca
[Example input 2]
5
Bacac
Sample output
Sample Output
[Sample Output 1]
Yes
1
3
2
4
[Sample Output 2]
No
The code is actually:
1#include <iostream>2#include <cstdio>3 using namespacestd;4 intstack[5],cx[ -],TOP,N,XC,HC;5 Charch;6 intMain () {7Cin>>N;8 for(intI=1; i<=n;i++){9Cin>>ch;Ten if(ch=='A') {++hc;cx[xc]=hc;xc++;} One if(ch=='B'){ A if(top==4) {printf ("no\n");return 0;} -++hc;stack[top]=hc;top++; - } the if(ch=='C'){ - if(top==0) {printf ("no\n");return 0;} -cx[xc]=stack[top-1];xc++;top--; - } + } -printf"yes\n"); + for(intI=0; i<xc;i++) cout<<cx[i]<<Endl; A return 0; at}
There were only four of the problems that once let me through.
City of Angels