PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000230. Tổng hình dấu cộng (Cross Sum Matrix)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng hình dấu cộng (Cross Sum Matrix)
Cross Sum Matrix
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer matrix and radius , for each cell sum all cells in its row with and in its column with . Clip to the matrix boundaries and count the center once. Output the resulting matrix.
Input
The first line contains , followed by rows of integers.
Output
Print lines of cross sums each, in column order.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; .
Example 1
Input
2 3 1
1 2 3
4 5 6
Output
7 11 11
10 17 14
Explanation
Cell (1,2) includes 1,2,3,5, sum 11; cell (2,2) includes 4,5,6,2, sum 17.
Example 2
Input
1 2 0
-7 5
Output
-7 5
Explanation
Radius zero keeps only the center.