//
// main.cpp
//
//
// Created by LIMIN-RONG on 2015/5/31.
//
//
#include <stdio.h>
int main(){
int cases;
scanf("%d",&cases);
for(int i=0 ; i<cases ; i++){
int m , n , q ;
scanf("%d %d %d",&m,&n,&q);
char grid[m][n];
for(int i = 0 ; i < m ; i++){
scanf("%s",&grid[i][0]);
}
int a[q],b[q];
for(int i =0 ; i<q ; i++){
scanf("%d %d",&a[i],&b[i]);
}
printf("%d %d %d\n",m,n,q);
for(int i = 0 ; i < q ; i++){
int r = a[i] , s =b[i];
int size = 1 ;
bool tag = true;
for(int range = 1 ; r-range>=0 && r+range<m && s-range>=0 && s+range<n ; range++ ){ //range to scale
for (int row = r - range; row <= r+range ; row++) { //check from top-left to buttom-right
for(int column = s - range ; column <= s+range ; column++){
if(grid[row][column]!=grid[r][s])
tag = false;
}
}
if(tag==true)
size+=2;
else
break;
}
printf("%d\n",size);
}
}
return 0;
}
沒有留言:
張貼留言