3120 - I2P(I)2024_Hu_Lab8 Scoreboard

Time

2024/11/11 18:30:00 2024/11/11 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11711 Dynamic 3D array
14501 Syaoran's Challenge

11711 - Dynamic 3D array   

Description

In this problem, you are asked to design two functions
    1.

unsigned*** new_3d_array(unsigned n,unsigned m,unsigned k);

malloc an n*m*k 3D unsigned array, and then return its address. The main function will check the correctness of your array.

 

    2.

void delete_3d_array(unsigned ***arr);

Free the memory space of your array that was previously allocated by using malloc. Be careful about the memory uage of your program allocated dynamically so as to avoid MLE.

 

The two functions have been declared in function.h, and you are asked to complete the function definitions in function.c.

Your program should construct the 3D array by using only three malloc function calls. Notice that malloc is a time-consuming operation.

 

Note: for OJ submission:

       Step 1. Submit only your function.c into the submission block. (Please choose C compiler) 

       Step 2. Check the results and debug your program if necessary.

Input

Please refer to the main function.

The input only has one line, consisting of five positive integers t,n,m,k,r separated by space characters, where t is the number of tests, (n,m,k) represents the array size, and r is a parameter for testing. 

Note that n*m*k<=10000000 and t*n*m*k<=60000000

Output

In order to test your array's correctness, we will use your array to do some computations and output the results.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11711.c

Partial Judge Header

11711.h

Tags

Jinkela



Discuss




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