Coloring Practice
Time limit1sMemory limit512 MB
Count how many 3x3 subgrids contain exactly i black cells for each i from 0 to 9, given up to 1e5 black cells on a huge grid.
- Level
Medium6 of 10
- Topics
- Prefix sum, Hash map, Implementation, Combinatorics
- Solved
- No attempts yet
Problem
There is a grid of size , divided into cells. Of these, cells are black and the rest are white.
For every subgrid, find how many subgrids contain exactly black cells. ()
Input
The first line gives the size of the grid , and the number of black cells .
Each of the following lines gives the position , of a black cell, one per line. No cell is given more than once.
Output
Output the answers on 10 lines. On line , output the number of subgrids that contain exactly black cells. ()