Submission
Status:
PPP---PP-PP
Score: 70
User: Nathlol2
Problemset: ตั้งฐานทัพ
Language: cpp
Time: 0.000 second
Submitted On: 2024-11-29 17:51:56
#include <bits/stdc++.h>
using namespace std;
int mx[8] = {0,0,1,-1,1,-1,1,-1};
int my[8] = {1,-1,0,0,1,1,-1,-1};
int c;
int n, m;
string a[755];
int xx;
vector<vector<bool>> v(755,vector<bool>(755, false));
void bfs(int g,int h){
queue<pair<int, int>> q;
q.push({g,h});
c = 0;
while(!q.empty()){
int x = q.front().first;
int y = q.front().second;
q.pop();
if(!v[x][y]){
v[x][y] = true;
}else continue;
c++;
for(int i = 0;i<8;i++){
int nx = x + mx[i];
int ny = y + my[i];
if(nx < 0 || ny < 0 || nx >= n || ny >= m){
continue;
}
if(a[nx][ny] == '.' && !v[nx][ny]){
q.push({nx, ny});
}
}
}
xx = max(c, xx);
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 0;i<m;i++){
cin >> a[i];
}
for(int i = 0;i<m;i++){
for(int j = 0;j<n;j++){
if(a[i][j] == '.' && !v[i][j]){
c = 0;
bfs(i, j);
}
}
}
cout << xx;
}