2383 - Programming2021_practice Scoreboard

Time

2021/09/05 21:00:00 2021/09/27 11:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10162 Matrix multiplication
10424 Max pooling
11243 Number Tower
11244 Flip

10162 - Matrix multiplication   

Description

Given two matrices A and B of size m x n and n x p, calculate C = A x B.

The matrix multiplication is defined as follows:

         n
Cij Σ  Aik x Bkj
       k=1

Input

m n
A11 A12  ... A1n
...
Am1 Am2  ... Amn
n p
B11 B12 ... B1p
...
Bn1 Bn2 ... Bnp

Each entry is a positive integer no more than 20, and 0 < m, n, p < 10.

Output

C11 C12 ... C1p
...
Cm1 Cm2 ... Cmp

Print each entry with "%d " (a number followed by a whitespace)
Note that there is a newline character at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10424 - Max pooling   

Description

The input is an N by N matrix and the output is a new (N-2) by (N-2) matrix. Each element of the new matrix corresponds to the maximum value in each 3 by 3 region of the original matrix.

For example, if the original matrix is

10 20 30 90 30
50 60 30 20 50
80 50 70 60 20
90 40 30 20 80
20 30 40 50 90

then the new matrix will be

80 90 90
90 70 80
90 70 90

Input

The first number is the matrix size N, where 3 <= N <= 10.
The following N*N numbers are the elements of the N by N matrix.
The elements are all positive integers, ranging from 1 to 99.

Output

A new (N-2) by (N-2) matrix
Use “%3d” to print each element and add a newline at the end of each row.
You need to print a newline character at the end of each line. ('\n')

Sample Input  Download

Sample Output  Download

Tags




Discuss




11243 - Number Tower   

Description

There is a number tower which consists of many positive integers, and it looks like a triangle as below :
    1
   4 6
  6 9 3
 6 3 7 1
2 6 3 1 8

The first layer contains one positive integer, and the second one contains two, and so on. 

Our goal is to find a path from top to bottom which has the largest sum in all paths. The path starts from the root node (the first number in the first layer), and each node can only choose one of the nearest two descendant nodes to move to. For example, 4 in the second layer can only move to 6 or 9 in the third layer. Please, sum up all the number in the path and print the largest sum.

Input

The first line is a positive integer n, that represents the height of the tower. (n <= 10)
Each line in next n lines contains m positive integers whose value are not greater than 9 in the mth layer, 
and all number is seperated by white spaces.

Output

Print the largest value in all paths, and remenber to print a new line in the end of the anwser.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11244 - Flip   

Description

The input contains a string and K pairs of integers. Each pair contains two integers N and M. The operation is to flip the order of M characters that begins at the N-th position of the input string.

For example, consider the input string "SRVisHandsome", and the pair N = 3, M = 5. The character at position 3 is 'V' and the following 5 characters are "VisHa". Hence you have to flip the 5 characters into "aHsiV", and thus the string becomes "SRaHsiVndsome". Note that the input string contains no more than 1000 characters, and N+M-1 will not exceed the length of the string. A full example: If the input is
ABCDEFGH
3
3 5
5 4
2 6

The string will be changed as follows: ABGFEDCH => ABGFHCDE  =>  ADCHFGBE

Input

The first line is the input string. The second line is an integer K indicating there are K pairs of integers in the following K lines. Each pair of integers N and M represents the position of the starting character and the number of characters to be flipped.

Output

Print the final string after K rounds of flipping.

Sample Input  Download

Sample Output  Download

Tags




Discuss