#include<cstdio>
#include<cstring>
#define N 505
int R,C,K;
int flag[N][N];
int map[N][N];
__int64 sum[N][N];
int main()
{
scanf("%d%d%d",&R,&C,&K);
for ( int i = 0; i <= R+2; i++ )
for ( int j = 0; j <= C+2; j++ )
flag[i][j] = map[i][j] = sum[i][j] = 0;
char str[N];
for ( int i = 1; i <= R; i++ )
{
scanf("%s",str);
for ( int j = 0; str[j]; j++ )
flag[i][j+1] = str[j] - '0';
}
for ( int i = 1; i <= R; i++ )
{
for ( int j = 1; j <= C; j++ )
{
map[i][j] = flag[i][j] && flag[i-1][j] && flag[i+1][j] && flag[i][j-1] && flag[i][j+1];
sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + map[i-1][j-1];
}
}
__int64 res = 0;
int last_bot, last_col;
int top, bot, lt, rt;
int mark;
for ( top = 1, last_bot = 3; top <= R - 2; top++ )
{
mark = 0;
for ( bot = last_bot; bot <= R; bot++ )
{
for ( lt = 1, last_col = 3; lt <= C - 2; lt++ )
{
for ( rt = last_col ; rt <= C; rt++ )
if ( sum[bot][rt] - sum[bot][lt+1] - sum[top+1][rt] + sum[top+1][lt+1] >= K )
{
res += C - rt + 1; break;
mark++;
}
last_col = rt;
}
if ( mark == 1 )
last_bot = bot;
}
}
printf("%I64d\n",res);
}
Codeforces Beta Round #95 (Div. 2)
最新推荐文章于 2023-09-17 09:14:08 发布