-->
当前位置:首页 > 题库

PROGRAMMING:Train dispatching

Luz5年前 (2021-05-10)题库402
```
1 = = = = = < -- moving direction
/
3 =====
\
2 = = = = = > - moving direction
```
You may have seen "train car scheduling problem" in some data structure textbooks (of course, it doesn't matter if you haven't seen it). Today, we will actually operate the following car scheduling. Compared with the ASCII character diagram above, the problem is described as follows:
There are three parallel train tracks (1, 2, 3) and two connecting tracks 1-3 and 2-3. The existing train stops on track 1. Please use two connecting tracks and track 3 to transfer the train to track 2 in the required order. The rules are:
-Transfer one car at a time;
-The car on track 1 either enters track 3 through 1-3 connecting track (the operation is recorded as "1 - > 3"), or directly enters track 2 through two connecting tracks (the operation is recorded as "1 - > 2");
-Once the car enters track 2, it can not move out of the track;
-The car on track 3 can only enter track 2 through lane 2-3 (the operation is recorded as "3 - > 2");
-Obviously, no carriage can move through, across or around other carriages.
For the given stop sequence of No.1, if the required sequence of No.2 track can be realized through dispatching, the operation sequence is given; If not, ask the user are you kidding me?
###Input format:
Two lines of non empty string composed of capital letters. The first line represents the order of cars stopping on track 1 from left to right, and the second line represents the entry order of cars stopping on track 2 * * (input the second line of 'CBA' in example 1 to indicate that cars parking on track 2 from left to right is' ABC ', because' C 'enters first, so it is on the far right). The two lines of strings are the same length and no more than 26 (because there are only 26 uppercase letters), and each letter represents a car. The title ensures that the letters in the same line are not repeated, and the letter sets of the two lines are the same.
###Output format:
If it can be scheduled successfully, the shortest operation sequence is given, and each operation occupies one line. The so-called "shortest", that is, if the scheduling can be completed by 1 - > 2, it should not be realized by 1 - > 3 and 3 - > 2. If it cannot be scheduled, output "are you kidding me?"
###Input sample 1:
```in
ABC
CBA
```
###Output sample 1:
```out
1->3
1->3
1->2
3->2
3->2
```
###Input sample 2:
```
ABC
CAB
```
###Output sample 2:
```
Are you kidding me?
```






answer:If there is no answer, please comment