PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000228. Đếm ô theo từng màu (Rectangle Color Counts)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm ô theo từng màu (Rectangle Color Counts)
Rectangle Color Counts
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a static grid of colors A, B, C, indexed from 1, count the cells of each color in every inclusive rectangle .
Input
The first line contains . The next lines each contain a string of exactly characters A, B, C without spaces. Each of the next lines contains .
Output
Print lines, each containing three integers: the counts of A, B, C in that order.
Subtasks
- Subtask 1 (20 points): ; ; ; ; characters are A, B, C.
- Subtask 2 (30 points): ; ; ; ; characters are A, B, C; all cells are A.
- Subtask 3 (50 points): ; ; ; ; characters are A, B, C.
Example 1
Input
2 3 3
ABC
AAB
1 1 2 3
1 2 2 2
2 3 2 3
Output
3 2 1
1 1 0
0 1 0
Explanation
The full grid has 3 A, 2 B, 1 C. Column 2 contains B,A; the last cell is B.
Example 2
Input
1 1 1
C
1 1 1 1
Output
0 0 1
Explanation
There is one C cell.