Logo
(追記) (追記ここまで)

21035번 - Simple Operations in Matrix 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB15613212285.315%

문제

Matrix is a mathematical object which arranges data into a rectangular array of N rows and M columns. The rows are indexed from 1 to N, while the columns are indexed from 1 to M. Matrix is very powerful and extremely useful in many applications. In this problem, we are going to focus on two simple operations in matrix: row addition and column addition.

You are given a matrix of integers of N rows and M columns, and Q queries of the following format:

  • row k val: add each element on the k-th row by val,
  • col k val: add each element on the k-th column by val.

Your task is to output the following three numbers after all queries have been performed:

  • sum: the sum of all elements in the matrix,
  • min: the value of the smallest element in the matrix,
  • max: the value of the largest element in the matrix.

See the sample input for clarity

입력

The first line contains two integers: N M (1 ≤ N, M ≤ 50) denoting the size of the matrix (number of rows and columns, respectively). The next N lines, each contains M integers: Ai,j (-100 ≤ Ai,j ≤ 100) denoting the matrix element at the i-th row and j-th column for 1 ≤ iN and 1 ≤ jM, respectively. The next line contains an integer: Q (0 ≤ Q ≤ 100) denoting the number of queries. The next Q lines, each contains a query in one of the following format:

  • row k val (1 ≤ kN; -100 ≤ val ≤ 100)
  • col k val (1 ≤ kM; -100 ≤ val ≤ 100)

출력

The output contains three integers (each separated by a single space) in a single line: sum min max, as described in the problem statement.

제한

예제 입력 1

3 4
1 1 1 1
1 1 1 1
1 1 1 1
2
row 1 3
col 4 -2

예제 출력 1

18 -1 4

These are the matrices after each queries for the first sample.

예제 입력 2

4 3
10 10 10
10 10 10
10 10 10
10 10 10
5
row 2 -5
col 3 6
col 1 -10
row 4 7
col 1 3

예제 출력 2

122 -2 23

예제 입력 3

2 3
15 7 8
31 1 14
3
row 2 -15
col 1 10
row 1 2

예제 출력 3

57 -14 27

These are the matrices after each queries for the third sample.

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2017 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /