2170 - I2P(I)2020_Hu_hw7 Scoreboard

Time

2020/11/16 21:00:00 2020/11/23 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11711 Dynamic 3D array
12498 Parital Judge Example
12988 K-partition problem
12989 Parentheses problem

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




12498 - Parital Judge Example   

Description

This is the partial judge example (another method for online judge), you are asked to design a function below:

int call_add(int a, int b);

(implement a function to add two pass value togeter)

Note: for OJ partial judge 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.

/* the content below is what you need to copy and submit to oj*/

int call_add(int a, int b){

        return a + b;

}

More information about the different of partial judge and normal judge

Input

Please refer to the main function.

The input only one line, contain two number a and b  (1 < a < 10, 1< b < 10)

Output

Output a + b. 

Sample Input  Download

Sample Output  Download

Partial Judge Code

12498.c

Partial Judge Header

12498.h

Tags




Discuss




12988 - K-partition problem   

Description

Given an integer sequence which contains N positive integers, please output whether the sequence can be partitioned into K equal sum subsets. For example, 

Input sequence = 2, 1, 3, 9, 5, 2, 1, 5, K = 2

We can partition it into two equal sum subsets as the following shows:

Subset 1: 1, 1, 3, 9 , sum = 14

Subset 2: 2, 2, 5, 5 , sum = 14

Therefore, we should output 'True' as the answer.

Notice: For each testcase, you will get q sequence to deal with.

Input

First line contains an integer q which denotes the number of the sequences. (1 ≤ q ≤ 20)

The following 2×q lines denote all the sequences in the testcase.

For each sequence,

first line contains two integers N, K which denote the length of the sequence and partition number. (2 ≤ N ≤ 10, 2 ≤ K ≤ 5)

second line contains N integers seperated by blanks which denote the input sequence.

(1 ≤ each number in the given sequence < 30)

Output

Output contains q lines.

For each line, output the answer of the corresponding sequence ended with a newline.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12989 - Parentheses problem   

Description

Given a string which only contains '(' and ')' , you are asked to compute the value of the given string based on the following rules.

Supposed that A and B are both string which only contain '(' and ')'.

Rule 1: () = 1

Rule 2: (A) = 2 × A . For example, (()) = 2 × () = 2 × 1 = 2

Rule 3: AB = A + B . For example, ()() = 1 + 1 = 2

Computation process example:

Input string = (()(())) = 2 × ()(()) = 2 × [1 + (())] = 2 × [1 + 2 × ()] = 2 × [1 + 2 × 1] = 6

Notice: We guarantee that the given string is legal to compute. Therefore, testcases will not contain the following illegal cases.

illegal cases examples: ((), ))((

Input

First line contains an integer N which denotes the length of the given string. (2 ≤ N ≤ 100)

Second line contains N characters which denotes the input parentheses string.

Output

An integer which represent the value of the given string. (We guarantee that the answer can be stored in long long)

(Don't forget to print '\n' at the end of the line)

Sample Input  Download

Sample Output  Download

Tags




Discuss