#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int mod=1e9+7;
int n,m;
char c[303][303];
int sum[303][303];
int calc(int x,int y,int x2,int y2)
{
return sum[x2][y2]-sum[x-1][y2]-sum[x2][y-1]+sum[x-1][y-1];
}
signed main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>c[i][j];
sum[i][j]=(c[i][j]=='.');
sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
}
}
int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(c[i][j]=='#') continue;
for(int l=1;l<=n;l++)
{
if(i+l-1>n) break;
if(calc(i,j,i+l-1,j)!=l) break;
int s=j,e=m;
while(s<e)
{
int mid=s+(e-s+1)/2;
if(calc(i,j,i+l-1,mid)==l*(mid-j+1))
{
s=mid;
}
else
{
e=mid-1;
}
}
int sz=(s-j+1);
ans+=l*(sz*(sz+1)/2);
}
}
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1064 KB |
Output is correct |
2 |
Correct |
48 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1104 KB |
Output is correct |
2 |
Correct |
46 ms |
1040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
336 ms |
1076 KB |
Output is correct |
2 |
Correct |
55 ms |
1076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
1948 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
35 ms |
2008 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
34 ms |
1984 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
1996 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
46 ms |
1944 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |