2182 - I2P(I)2020_Yang_HW10 Scoreboard

Time

2020/11/24 21:00:00 2020/12/01 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11291 Mouse Maze
11711 Dynamic 3D array
12490 Little Brick's Calculator

11291 - Mouse Maze   

Description

Write a program that simulates a mouse in a maze. The program must count the steps taken by the mouse from the starting point to the final point.

The maze type is shown in following figure:

S$###
$$#$$
$$$##
##$$F

it consists of S (starting point), #(walls), $(road) and F (final point).

In above case, it needs 7 steps from S to F as following figure,

S$###
$$#$$
$$$##
##$$F

and the mouse can move in the four directions: up, down, left, right. There may be more than one way to reach final point, the program only need to print the least steps.

If there is no way from S to F, then print -1.

Input

The first line has an integer N(1<=N<=10^6), which means the number of test cases.

For each case, the first line has two integers. The first and second integers R and C (3<=R, C<=500) represent the numbers of rows and columns of the maze, respectively. The total number of elements in the maze is thus R x C.

The following R lines, each containing C characters, specify the elements of the maze.

Output

Print out the least steps for each case, and there is a new line character at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




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




12490 - Little Brick's Calculator   

Description

Little Bricks(小磚頭) has a very brilliant calculator,
it can parse the number from the a sentense and sum up all the numbers in the sentense.

One day, he broke the calculator,
but the calculator cannot be bought anymore,
so he ask you to make a new one for him.

ouo.

Hint:
This is a Partial Judge Problem:
0. You will be provided 2 files below: 'main.c', 'function.h'. You should only upload your 'solver' function inside a your '.c' file.
1. The 'main.c' file contains input, output, and function call, the 'function.h' file contains the defination of 'solver' function, and your '.c' file should contain the implement of 'solver' function.
2. You can compile multiple file by command, ex: 'gcc main.c function.h your_code.c', or create a project in your IDE.
3. Remember to include 'function.h'.

 

main.c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
#include "function.h"

#define maxn 1000

char input[1000010];

int main() {
    int sum = 0;
    int a[maxn];
    int *ptr[maxn];

    for (int i = 0; i < maxn; i++) {
        a[i] = 0;
        ptr[i] = &a[i];
    }

    scanf("%s", input);
    int n = solver(ptr, &sum, input);
    printf("%d", a[0]);
    for (int i = 1; i < n; i++)
        printf(" %d", a[i]);
    printf("\n%d\n", sum);
    return 0;
}

function.h

1
2
3
4
5
#ifndef FUNCTION_H
#define FUNCTION_H

int solver(int **ptr, int *sum, char *s);
#endif


For example, if the sentense is 'Now:12/31,23:59',
then you should parse the 4 numbers: 12, 31, 23, 59 out,
and calculate the sum of these numbers, which is 12+31+23+59=129

The numbers should be separate by a space, after a newline character, output the sum of numbers.
Note that your calculator should be able to handle negative number.

Input

Input contain only 1 line, a string S.

It is guarantee that:
0. 1<= |S| <= 10^6
1. Numbers in S will be in the range [-10^5, 10^5]
2. The ammount of number in S will be in the range [1, 1000]

Output

Output contains 2 lines.

The first line should output all numbers appear in the input string S, separate with a space character,
the next line should be the sum of numbers at the first line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12490.c

Partial Judge Header

12490.h

Tags




Discuss