#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool arr[2005][2005];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int n,m;
bool inbound(int x,int y){
return (x>=0 && y>=0);
}
int xpymax,xpymin,xmymax,xmymin;
int cnt = 0;
void dfs(int x,int y){
arr[x][y]=1;
cnt++;
xpymax = max(xpymax,x+y);
xpymin = min(xpymin,x+y);
xmymax = max(xmymax,x-y);
xmymin = min(xmymin,x-y);
for(int i=0;i<4;i++) if(inbound(x+dx[i] , y+dy[i])) if(arr[x+dx[i]][y+dy[i]]==0) dfs(x+dx[i],y+dy[i]);
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>m;
for(int i=0;i<2005;i++){
arr[i][m+4]=1;
arr[n+4][i]=1;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char a;cin>>a;
if(a=='#') arr[i][j]=1;
}
}
int ans = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(!arr[i][j]) {
xpymax = xmymax = INT_MIN;
xpymin = xmymin = INT_MAX;
cnt = 0;
dfs(i,j);
if(xpymax-xpymin!=xmymax-xmymin || (xpymax-xpymin)%2) continue;
int l = (xpymax-xpymin)/2+1;
int area = (2*l*l)-(2*l)+1;
if(cnt == area) ans++;
}
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4820 KB |
Output is correct |
2 |
Correct |
3 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4184 KB |
Output is correct |
4 |
Correct |
3 ms |
4560 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4308 KB |
Output is correct |
7 |
Correct |
2 ms |
4308 KB |
Output is correct |
8 |
Correct |
2 ms |
4308 KB |
Output is correct |
9 |
Correct |
3 ms |
4308 KB |
Output is correct |
10 |
Correct |
2 ms |
4308 KB |
Output is correct |
11 |
Correct |
2 ms |
4308 KB |
Output is correct |
12 |
Correct |
2 ms |
4692 KB |
Output is correct |
13 |
Correct |
2 ms |
4176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4820 KB |
Output is correct |
2 |
Correct |
3 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4184 KB |
Output is correct |
4 |
Correct |
3 ms |
4560 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4308 KB |
Output is correct |
7 |
Correct |
2 ms |
4308 KB |
Output is correct |
8 |
Correct |
2 ms |
4308 KB |
Output is correct |
9 |
Correct |
3 ms |
4308 KB |
Output is correct |
10 |
Correct |
2 ms |
4308 KB |
Output is correct |
11 |
Correct |
2 ms |
4308 KB |
Output is correct |
12 |
Correct |
2 ms |
4692 KB |
Output is correct |
13 |
Correct |
2 ms |
4176 KB |
Output is correct |
14 |
Correct |
253 ms |
238104 KB |
Output is correct |
15 |
Correct |
51 ms |
7928 KB |
Output is correct |
16 |
Correct |
135 ms |
8452 KB |
Output is correct |
17 |
Correct |
165 ms |
118556 KB |
Output is correct |
18 |
Correct |
74 ms |
8780 KB |
Output is correct |
19 |
Correct |
119 ms |
34944 KB |
Output is correct |
20 |
Correct |
138 ms |
51964 KB |
Output is correct |
21 |
Correct |
122 ms |
41852 KB |
Output is correct |
22 |
Correct |
110 ms |
16636 KB |
Output is correct |
23 |
Correct |
104 ms |
23940 KB |
Output is correct |
24 |
Correct |
113 ms |
22080 KB |
Output is correct |
25 |
Correct |
214 ms |
172728 KB |
Output is correct |
26 |
Correct |
69 ms |
8268 KB |
Output is correct |