Matrix Test

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

KurbyDoo has just learned about 2d matrices! Unfortunately, he can never seem to implement them properly.

Can you show him how its done?

Input Specifications

The first line will contain two integers N (1 \le N \le 250) and M (1 \le M \le 250) the number of rows and the number of columns in the matrix.
The next N lines will contain M space separated integers v_{ij} (1\le v_{ij} \le 10^9), the value in the ith row and jth column of the matrix.
The next line will contain a single integer Q (1 \le Q \le 5 \cdot 10^5) the number of queries.
The next Q lines will consist of three operations:

  • C i j v, Change the value at the ith row and jth column of the matrix to a value v.
  • Q i j, Query the value at the ith row and jth column of the matrix.
  • M i j, Query the largest value that has ever been located in the ith row and jth column of the matrix.

Output Specification

For each Q operation, output the value at the ith row and jth column of the matrix.
For each M operation, output the largest value that has ever been located in the ith row and jth column of the matrix (values from the creation of the matrix are included).

Sample Input 1

4 3
2 4 2
6 3 7
2 3 6
9 3 9
4
Q 3 2
Q 1 1
Q 4 1
Q 3 1

Sample Output 1

3
2
9
2

Sample Input 2

2 2
1 10
3 7
5
Q 1 2
Q 2 2
C 1 2 3
Q 1 2
M 1 2

Sample Output 2

10
7
3
10

Comments

There are no comments at the moment.