問題一覧 > 通常問題

No.3677 Global Checksum

レベル : / 実行時間制限 : 1ケース 0.200秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 46
作問者 : 👑 みうね / テスター : harurun TKTYI
お気に入りにしたユーザー ProblemId : 13851 / 自分の提出
問題文最終更新日: 2026-09-03 22:51:33
Global Checksum
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 512 BONSAI (順位表) の他の問題:

Note: The execution time limit for this problem is set very strictly.

Problem Statement

You are given a table $A$ of integers with $H$ rows and $W$ columns.

For each row $i\ (1 \leq i \leq H)$, define its checksum $S_i$ as

$$S_i = \left(\sum_{j=1}^{W} A_{i,j}\right) \bmod 2^{32}$$

. Also, define the checksum $T$ of the entire data as

$$T = \left(\sum_{i=1}^{H} S_i\right) \bmod 2^{32}$$

.

For each row $i\ (1 \leq i \leq H)$, define the verification code $C_i$ as

$$C_i = (S_i+T) \bmod 2^{32}$$

. Find $C_1,C_2,\ldots,C_H$.

Input

The input is given from Standard Input in the following format.

$H\ W$
$A_{1,1}\ A_{1,2}\ \ldots\ A_{1,W}$
$A_{2,1}\ A_{2,2}\ \ldots\ A_{2,W}$
$\vdots$
$A_{H,1}\ A_{H,2}\ \ldots\ A_{H,W}$

Constraints

  • $1\le H\le 10^6$
  • $1\le W$
  • $HW\le 4\times 10^6$
  • $0\le A_{i,j}<10^9$
  • All input values are integers.

Output

Output $C_1,C_2,\ldots,C_H$ in this order, one per line, each as a non-negative integer in decimal notation.

Print a newline at the end of the output.

Sample

Sample 1
Input
3 2
1 2
3 4
5 6
Output
24
28
32

The checksums of the rows are $3,7,11$ in order, and $T=21$. Therefore, the verification codes are $24,28,32$ in order.

Sample 2
Input
2 5
900000000 900000000 900000000 900000000 900000000
999999999 0 1 999999998 500000000
Output
2910065406
910065404

The sum of row $1$ is $4500000000$, so $S_1=205032704$. Also, $S_2=2499999998$, so $T=2705032702$. Therefore, $C_1=2910065406, C_2=910065404$.

Sample 3
Input
4 3
0 1 2
999999999 999999998 999999997
400000000 400000000 400000000
123456789 987654321 42
Output
1016143856
4016143847
2216143853
2127255005

The checksums of the rows are $3,2999999994,1200000000,1111111152$ in order. The remainder when their sum is divided by $2^{32}$ is $1016143853$, so $T=1016143853$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。