cswork / OA打开练习工作台

KoddiOA #4

Count 2x2 Submatrices by Black Cell Count

估计中等可在线判题

考点(AI 标注)哈希计数

Given the coordinates of all black cells in a rows×cols grid. Classify each 2×2 submatrix by the number of black cells it contains, 0..4, count each class, and return the five counts. Coordinates start from 0 and contain no duplicates.

The statement is explicit; this site adds the coordinate ranges, the distinctness of black cells, and the input protocol.

输入格式

The first line contains rows cols k (1≤rows,cols≤10^9, 0≤k≤min(rows×cols,200000)); the next k lines give the 0-based row col of each black cell.

输出格式

Output 5 integers: the numbers of windows containing 0, 1, 2, 3, and 4 black cells, in that order.

样例 1

输入:

3 3 2
0 0
1 1

输出:

0 3 1 0 0

样例 2

输入:

1 5 0

输出:

0 0 0 0 0

样例 3

输入:

2 2 4
0 0
0 1
1 0
1 1

输出:

0 0 0 0 1