3328 - I2P(II)2026_Kuo_Lab4 Scoreboard

Time

2026/05/05 16:00:00 2026/05/05 16:01:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14605 Matrix Operation
14941 Vending Mid

14605 - Matrix Operation   

Description

In this problem, you are asked to implement a class Matrix that represents a $N\times N$ Matrix.

Following are the methods you should implement:

  1. add A.add(B) → $A = A+B$
  2. subtract A.subtract(B) → $A = A-B$
  3. multiply A.multiply(B) → $A = AB$
  4. transpose A.transpose() → $A = A^{\top}$
  5. power A.power(x) → $\underbrace{AA \dots AA}_{\times x}$

Usefull links

Power of matrix:

Reference

Input

The first line contains two integers $N$, $T$, representing the size of the matrix and the number of the operations.

Following are $N$ lines, each line contains $N$ integers, representing the element in the starting matrix.

Following are $T$ operations, each operation start with an interger $o$, representings the type of the operation.

For operation type 1, 2, 3, interger $o$ is followed by $N\times N$ numbers, representing the element in the operand matrix.

For operation type 5, interger $o$ is followed by an interger $x$, repersentings $x$-th power.


Constraints

  • $1 \leq N \leq 10$
  • $1 \leq T \leq 1000$
  • $o = {1,2,3,4,5}$
  • $1 \leq x \leq 1e6$
  • All numbers would not exceed the range of long long.

Subtask

  1. (Testcases 1-6) $o = {1,2,3,4}$
  2. (Testcases 7-8) $1 \leq x \leq 5$
  3. (Testcases 9-10) No additional constraints.

Output

Output the final result of the matrix.

Sample Input  Download

Sample Output  Download

Partial Judge Code

14605.cpp

Partial Judge Header

14605.h

Tags




Discuss




14941 - Vending Mid   

Description

SpongeBob is hungry while waiting the bus. As a vending machine, now you want to sell the median-price kandy to SpongBob.

The Median Price is defined as the price of the element at index [(size - 1) / 2] in the sorted list of kandy prices.

If you have the following kandy prices: [10, 25, 40, 50], whose size is 4 and index is 0-based, then you should sell the kandy at index (size - 1) / 2 =  1.

If you have the following kandy prices: [10, 25, 40, 50, 100], whose size is 5 and index is 0-based, then you should sell the kandy at index (size - 1) / 2 =  2.

This is a partial judge probelm. Please implement these two functions:

  1. store <price>: Add an item with a given price (integer) into the vending machine.

  2. sell: Sell the Median-Price kandy. If the machine is empty, ignore this command.

Constraints

  • number of operations <= 2 * 105.
  • price <= 109.

 

Please note that you CANNOT use STL to solve this problem.

Input

A sequence of commands (store <num> or sell).

Output

A single line containing two integers separated by a space:

  1. The total number of items sold.

  2. The total revenue with '\n'.

Sample Input  Download

Sample Output  Download

Partial Judge Code

14941.cpp

Partial Judge Header

14941.h

Tags




Discuss