Under construction

Still being built. Things may change

Andres Iniesta

Time limit1sMemory limit128 MB

Summary
You remove up to K obstacles and choose a standing cell to maximize visible cells in its row and column.
Level

Medium5 of 10

Topics
Brute force, Prefix sum, Matrix
Solved
No attempts yet

Problem

Midfielder Andres Iniesta trains on an N×MN \times M grid where some cells hold obstacles. He stands on an empty cell and sees every cell in the same row or column with no obstacle between them, including his own cell.

Iniesta can destroy obstacles with a ball, at most KK times. After destroying obstacles, find the maximum number of cells he can see from some empty cell. He may stand on a cell that was empty initially or on a cell whose obstacle he destroyed.

Input

The first line contains NN, MM, and KK: the number of rows, columns, and the maximum obstacles he may destroy.

Each of the next NN lines has MM characters: . for an empty cell and * for an obstacle.

Output

Print one integer: the maximum number of visible cells after destroying up to KK obstacles and standing on an empty cell.

Constraints

  • 1≤N,M≤2001 \le N, M \le 200
  • 0≤K≤500 \le K \le 50

Hint

Only obstacles on Iniesta's row and column affect his view from a chosen cell. For each candidate cell, try destroying up to KK obstacles on that row and column and count visible cells.

Examples3

  1. Example 1

    Input
    7 4 5
    ***.
    **.*
    ..*.
    **.*
    ****
    *.**
    ****
    
    Expected output
    10
    
  2. Example 2

    Input
    1 1 0
    .
    
    Expected output
    1
    
  3. Example 3

    Input
    1 3 1
    .*.
    
    Expected output
    3