14503 - Fake Cardcaptor   

Description

You have heard about Cardcaptor Sakura Question, but it's too easy. Maybe we can make it a little bit complex?

There are MAX_ARRAY maximum tables and MAX_ELEMENTS maximum elements for each table. Your problem is to modify the functions below:

[1] placeFunction

Param:
index size
a0, a1, ..., asize-1

Push a new element to specified index from behind
If pushing a new element exceed the maximum limit of elements, ignore the elements

Before Commands After
2: 5 5 5 1 2 5
1 2 3 4 5

1 5 3
8 8 8
2: 5 5 5 1 2 3 4 5
5: 8 8 8

 

[2] deleteFunction

Param:
index

To delete the table from specified index

Before Commands After
2: 5 5 5 1 2 3 4 5
5: 8 8 8
2 5 5: 8 8 8

 

[3] swapFunction

Param:
index1 index2

Swap table of index1 and index2

Before Commands After
2: 10 11
5: 8 8 8

3 2 5

3 2 7

5: 10 11

7: 8 8 8

 

[4] reverseFunction

Param: None

Reverse the order of existing (non empty) table
e.g. if the table only exist (non empty) index 3, 5, 6, 23 you need to reverse the order as
3->23, 5->6, 6->5, 23->3, and the remaining of the tables will still remains empty

Before Commands After

5: 1 2 3 4 5

8: 9 9 9

200: 50 77

4

5: 50 77

8: 9 9 9

200: 1 2 3 4 5

 

[5] popFunction

Param:
index pop_num

Pop the last elements of the table[idx] pop_num times
If it exceed the amount of existing elements, then you can stop in remove all

Before Commands After

5: 1 2 3 4 5

8: 9 9 9

200: 50 77

5 8 4

5 5 2

5: 1 2 3

200: 50 77

 

[6] shiftFunction

Param:
shift_num

Shift the table index by shift_num
If it's positive, shit to the right, and if it's negative shift to the left

Before Commands After

5: 1 2 3

200: 50 77

6 -10

190: 50 77

995: 1 2 3

 

[7] sortFunction
Param:
index

Sort the table[idx] from lowest to highest

Before Commands After
2: 3 7 4 6 5
5: 8 8 8
7 2

2: 3 4 5 6 7

5: 8 8 8

 

[8] printFunction
Param: None

Print the non empty table with a index as the header, and ignore the empty one
e.g. if the only non empty table are index 2 and 6
then your print format will be
2: a[2, 0], a[2, 1], ... 
6: a[6, 0], a[6, 1], ... 
idx:[space]num1[space]num2...[space]numn-1[newline]
If all table are empty, print "Empty QQ" followed by '\n'

This is a partial judge, you only need to implement the functions and scan the given parameters

Input

There are T instructions

For each instruction, the input will be idx param

param will be unique based on the functions describe

0 <= Index <= MAX_ARRAY-1

0 <= ai, size, pop_num <= MAX_ELEMENTS

-105 <= shift_num <= 105

Output

See the print function format in the description

Sample Input  Download

Sample Output  Download

Partial Judge Code

14503.c

Partial Judge Header

14503.h


Discuss