3097 - I2P(I)2024_Hu_Mid1 Scoreboard

Time

2024/10/14 18:30:00 2024/10/14 21:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13812 Advanced Convolution
14471 Pocky Challenge
14472 Roman to Integer

13812 - Advanced Convolution   

Description

In this problem, you have to implement a 2D convolution operation with zero-padding and stride.

Convolution is an operation that you elementwise multiply the sub-region in the original image(A larger 2D array) and the provided kernel(A smaller 2D array) and the summation of the multiplied values will be the new values in the output map(The size may be different from the original image). The multiplication follows a sliding window, so once we reach the bottom-right, we'll get a brand new 2D map.

 

Once you understand how to do simple convolution, another trick in convolution is that you can pad the original map with zeros, which is called zero-padding.

 

Last, we can decide the step size of the sliding window, which is called stride.

 

To sum up, you'll be given a 2D image and a 2D kernel, you are asked to do the convolution with the given padding size and stride.

Testcase 1~3: No padding, stride = 1 (Simple convolution)
Testcase 4: No padding, stride > 1 (Only considering stride)
Testcase 5: With padding, stride =1 (Only considering padding)
Testcase 6: With padding, stride > 1

 

Note that you only have to do the convolution in the valid region.

 

 

Input

The first line contains 2 integers, the height and the width of the 2D image, respectively. (1 <= height, width <= 1024)

Next, you have to read the whole 2D image.

The following line contains 2 integers, the height and the width of the 2D kernel, respectively. (1 <= height, width <= 10)

Then, you have to read the whole 2D kernel.

The last line will be the the size of stride and padding, respectively. (0 <= size of stride and padding <= 10)

 

All the values mentioned above are integers.

It is guaranteed every value of 2D images <= 255 and and 2D kernel is <= 10

Output

Please print the calculated 2D map.

The elements are separated by whitespace and you have to print '\n' at the end of each row.

Sample Input  Download

Sample Output  Download

Tags




Discuss




14471 - Pocky Challenge   

Description

Pocky is a sweet snack food, a biscuit stick that is very delicious!

Buy Glico Japanese Pocky - Cacao 60% at Tofu Cute

As we are a CS students, our Pocky is described by 1D array with length blocks. The pocky could be eaten from the most left or most right.

Also since 福昌 is a light eater, he won't eat all of the pocky, as he only can eat K blocks, however he want the maximum value from eating blocks

 

For example given the Pocky array:

If the K = 3, The maximum value can be gathered from eating from the right block three times, as total value = 1 + 15 + 2 = 18

If the K = 5, The maximum value could be get by eating 2 block from the right side, and then 3 block from the left side, as total value = 1 + 15 + 1 + 7 + 8 = 32

 

Your task is to calculate the maximum value from given Pocky array and K.

 

HINT

There are 2 ways to solve this problem
1. Make 2 prefix sum from beginning of the array and end of the array, and compare each value related to K
2. Try to do this iteratively:
Calculate the sum of first K elements
Calculate the sum of first K-1 elements and one lastest element
Calculate the sum of first K-2 elements and 2 lastest elements
And so on ...
until you calculate sum of lastest K elements

Input

There are T testcases

Each testcase has  

  • N and K, separated by space in the first line
  • ao​, a1​, a2​, ..., aN-1 in the second line

1 <= T <= 50

1 <= K <= N <= 50000

1 <= ai <= 109

Output

print the maximum value followed by newline character for each testcase

Sample Input  Download

Sample Output  Download

Tags




Discuss




14472 - Roman to Integer   

Description

Mr. Tim was assigned to gather data about the number of elephants in each country. However the data numbers are shown using Roman Symbols, your task is to translate the Roman number into an integer

 

Roman numbers are represented by symbols IVXLCD, and M, and below is the table of each symbol value

Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

Here is the rule of legal roman:

  1. Symbol can be repeated to representing some value IX, and C, and M can be repeated, for a maximum of 3 times, example:
    III representing 3 (1+1+1 = 3)
    XX representing 20
    CCCC is illegal (more than 3 consecutive symbols)
    VV is illegal (only I, X, C, and M is allowed)
  2. Some combinations can represent subtractive notation, the full list is:
    IV representing 4 (5-1)
    IX representing 9 (10-1)
    XL representing 40 (50-40)
    XC representing 90 (100-10)
    CD representing 400 (500-100)
    CM representing 900 (1000-100)
    Other subtractive notation combinations (e.g. IC) are illegal
  3. The roman must be in descending order (Biggest to Lowest) to make a combination for example:
    XXVII representing 27 (10+10+5+1+1)
    Subtractive notation can be also put as long as it's in order, for example:
    XIV representing 14 (10 + (5 - 1))
    MXCI representing 1091 (1000 + (100 - 10) + 1)
    XXXIX is legal, representing 39 (10 + 10 + 10 + 9)
    MIC is illegal as it's not in descending order and the symbol IC is not included in rule number 2
    MDD is illegal as it violate rule number 1

    XXL is illegal as XL > X and L > XX, no correct combination here
    XLXL is illegal (the correct way to represent 80 is LXXX, the same subtractive notation can't be consecutive)
    IXI is illegal (there is a more simple way to represent 10, which is X)

Your task is to determine if the number is legal or illegal, if it's legal try to convert the roman to integer representation

Input

There are T testcases

1 <= T <= 100
Each testcase will have only 1 string

Length of string will be <= 20

For testcase 1~3: no illegal format, no subtractive notation, guaranteed in descending order
For testcase 4~5: no illegal format, subtractive notation exist
For testcase 6: no further restriction

Output

For each testcase, please print the number in integer, following by newline character

If it's in illegal format, print "QQ" without the quotes

Sample Input  Download

Sample Output  Download

Tags




Discuss