14501 - Syaoran's Challenge   

Description

Syaoran is Sakura's rival. He heard Sakura was creating a card-playing program, so he decided to create a new program with even more functions.

There are 10 piles of cards (indexed from 0 to 9) and no cards on them initially.

Given a command S, Syaoran's program has to follow the instructions below:

(1)

print

: Print the status of each pile with the format: "[index]: [cards_sequence]\n", e.g. "0: 1 3 3 4 5\n". If there are no cards, print "No card" where the card_sequence should have been, e.g. "0: No card\n"

(2)

all [num] [len]

: Replace all piles with len cards of value num.

For example, the instruction "all 3 4" changes the status of each pile to "index: 3 3 3 3\n";

(3)

place [index] [len]
[integer_sequence]

: Change the status of Pile index to the sequence integer_sequence, whose length is len

For example, if the instruction is:

place 2 3
3 2 1

The status of Pile 2 becomes:

2: 3 2 1

(4)

swap [index_a] [index_b]

: Swap the cards on Pile index_a and Pile index_b.

For example, if the original status of Pile 0 and Pile 1 are:

0: 1 2 3
1: 4 5 6

after "swap 0 1", the status of the two piles becomes:

0: 4 5 6
1: 1 2 3

This instruction is valid even if one of the tables is empty.

(5)

clear

: Remove all cards from each pile.

(6)

reverse [start_index] [stop_index]

: Reverse the order of the piles from start_index to stop_index, inclusive. If stop_index is less than start_idx, it wraps around.

For example, if the original status of the tables is:

8: 8
9: 9 8
0: 10 9 8
1: 11 10 9 8
2: 12 9 6

After "reverse 9 1", the status becomes:

8: 8
9: 11 10 9 8
0: 10 9 8
1: 9 8
2: 12 9 6

(7)

exit

: Terminate the program

 

Input

Commands separated by a newline character.

Note that:

1 <= the value of each card <= 13

1 <= number of cards on each pile <= 10000

 

Note that only testcase 1, 5, and 6 contains reverse.

Output

Status of each table

Sample Input  Download

Sample Output  Download

Tags




Discuss