PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000265. Tăng các ma trận con thêm một (Increment Submatrices by One)
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 các ma trận con thêm một (Increment Submatrices by One)
Increment Submatrices by One
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
An initially zero matrix uses zero-based row and column indices. Each operation adds one to every cell of the inclusive rectangle with these opposite corners. Print the matrix after all operations.
Input
First line: . Next lines: .
Output
Print lines of space-separated integers.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Example 1
Input
3 2
1 1 2 2
0 0 1 1
Output
1 1 0
1 2 1
0 1 1
Explanation
Cell (1,1) is covered twice; other cells at most once.
Example 2
Input
2 1
0 0 1 1
Output
1 1
1 1
Explanation
One operation covers the entire matrix.