Codeforces Round 274 (Div. 1)
E
Parking Lot
Codeforces
2800
原题
← D→
翻译中…

Petya's been bored at work and he is killing the time by watching the parking lot at the office. The parking lot looks from above like an $*n* × *m*$ table (a cell of the table corresponds to a single parking spot). Some spots in the parking lot are taken, others are empty.

翻译中…

Petya watches cars riding into the parking lot one by one. After a car settles down at the parking spot, Petya amuzes himself by counting what maximum square of empty spots (i.e. a square subtable) can be seen on the parking lot if we look at it from above. Also, he takes notes of the square's size (side length) in his notebook.

翻译中…

You task is: given the state of the parking lot at the initial moment of time and the information about where the arriving cars park, restore what Petya wrote in his notebook. It is midday, so nobody leaves the lot.

翻译中…

Input

翻译中…

The first line contains three integers $*n*$, $*m*$ and $*k*$ — the sizes of the parking lot and the number of arriving cars after Petya started his watch ($1 ≤ *n*, *m*, *k* ≤ 2000$). Each of the following $*n*$ lines contains $*m*$ characters 'X' and '.', where 'X' means a taken spot and '.' means an empty spot. Each of the next $*k*$ lines contains a pair of integers $*x*_{*i*}$, $*y*_{*i*}$ — the number of row and column of the spot the corresponding car takes ($1 ≤ *x*_{*i*} ≤ *n*$, $1 ≤ *y*_{*i*} ≤ *m*$). It is guaranteed that this place was empty. You can assume that a car enters a parking lot only after the previous car successfully finds a spot.

翻译中…

Output

翻译中…

Print $*k*$ integers — the length of the side of the maximum square of empty spots after the corresponding car has entered the parking lot.

翻译中…

样例

Input #1
7 8 4
........
X.....X.
........
........
.X......
........
........
1 5
6 4
3 5
4 6
Output #1
5
4
4
3
InputCopy OutputCopy
题目信息
题号
480E
时间限制
3 s
内存限制
256 MB
标签
数据结构
分治

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。