#abc253f. F - Operations on a Matrix
F - Operations on a Matrix
Score : points
问题描述
我们有一个 矩阵,其元素最初全为 。
处理给定的 个查询。每个查询属于以下格式之一:
1 l r x
:将 加到第 列、第 列、……以及第 列的所有元素上。2 i x
:将第 行的所有元素替换为 。3 i j
:打印出第 个元素。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have an matrix, whose elements are initially all .
Process given queries. Each query is in one of the following formats.
1 l r x
: Add to every element in the -th, -th, , and -th column.2 i x
: Replace every element in the -th row with .3 i j
: Print the -th element.
Constraints
- Every query is in one of the formats listed in the Problem Statement.
- For each query in the format
1 l r x
, and . - For each query in the format
2 i x
, and . - For each query in the format
3 i j
, and . - At least one query in the format
3 i j
is given. - All values in input are integers.
Input
Input is given from Standard Input in the following format:
, which denotes the -th query, is in one of the following formats:
Output
For each query in the format 3 i j
, print a single line containing the answer.
Sample Input 1
3 3 9
1 1 2 1
3 2 2
2 3 2
3 3 3
3 3 1
1 2 3 3
3 3 2
3 2 3
3 1 2
Sample Output 1
1
2
2
5
3
4
The matrix transitions as follows.
$\begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 1 & 1 & 0 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 2 & 2 & 2 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 4 & 3 \\ 1 & 4 & 3 \\ 2 & 5 & 5 \\ \end{pmatrix}$
Sample Input 2
1 1 10
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
1 1 1 1000000000
3 1 1
Sample Output 2
9000000000
Sample Input 3
10 10 10
1 1 8 5
2 2 6
3 2 1
3 4 7
1 5 9 7
3 3 2
3 2 8
2 8 10
3 8 8
3 1 10
Sample Output 3
6
5
5
13
10
0
update @ 2024/3/10 10:47:59