Portraits
Limits: 1 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Lately, Zenik has loved making portraits of prominent historical
figures of Ukraine, as well as catchphrases, out of ... unusual
materials. A portrait can be imagined as a rectangular grid of size
\(n\) by \(m\), where cells are marked with
"." if they should be empty and "*" if an
unusual material should be placed in them. Since one piece of unusual
material is quite heavy (on average about \(74\) kilograms), Zenik brings the materials
by truck.
In one truck trip, Zenik can bring from \(1\) to \(k\) pieces of material. The truck is quite clumsy, so in one trip it is able to deliver materials to only one row. That is, before unloading the next batch of materials, Zenik chooses one row of the grid and unloads all materials in that exact row. Then Zenik goes for materials again, chooses a row again, and unloads all materials in the chosen row again, and so on until he lays out what he initially planned.
How many truck trips does Zenik need to make to lay out the portrait?
Input
The first line contains three numbers \(n\), \(m\), and \(k\) — the dimensions of the grid and the number of unusual materials that Zenik can transport in one go to a single row.
Each of the next \(n\) lines
describes the grid, consisting of the characters "." and
"*".
Output
Output a single number — the minimum number of truck trips Zenik must make in order to lay out the portrait.
Constraints
\(1 \le n, m, k \le 10^3\),
the grid consists entirely of the characters "." and
"*".
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 5 7 2 *.*.*** .*..*.. .*..*** .*..*.. .*..*** | 9 |
| Input (stdin) | Output (stdout) |
|---|---|
| 35 35 35 ................................... ................................... ................................... ..............******............... ...............******.............. ................*****.............. .........**.....****............... .......****........................ ......****......................... ......****......................... ......*****........................ ......******....................... ......******....................... ......******....................... .......*****......**.....*......... .......****.**.******.*****........ ........***..********..***......... .....*...*...***.*****.**.......... .................**.**............. ......**.............*............. .......*.............**............ .......**...........***............ .........*..........****........... ....................***............ ...............*.....**............ ..........**.........*.**.......... ...........**.....*******.......... ..........***************.......... .........*****************......... ........**********..**..***........ .......***.******************...... ......****.***********.********.... ....******..*******....**********.. ..********...*****.....************ **********.....**.....************* | 32 |
Notes
In the first test, to lay out the first row *.*.***, 5
unusual materials are needed. For this, Zenik must load the truck three
times with unusual materials.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|