Submission
Status:
PPPPPPPPPP
Score: 100
User: fluke
Problemset: หุ่นพัง
Language: cpp
Time: 0.003 second
Submitted On: 2025-02-02 22:18:47
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int n;
int di[]={-1,0};
int dj[]={0,-1};
cin>>n;
vector <string> mp(n);
for(int i=0;i<n;i++)
cin>>mp[i];
vector <vector <bool> > vis(n,vector <bool> (n));
int ans=0;
// up left
queue <pair<int,int> > bfs;
bfs.push({n-1,n-1});
while(!bfs.empty()){
int inow=bfs.front().first;
int jnow=bfs.front().second;
bfs.pop();
if(vis[inow][jnow])continue;
vis[inow][jnow]=true;
ans++;
for(int i=0;i<2;i++){
int ni=inow+di[i];
int nj=jnow+dj[i];
if(ni < 0 || ni >= n || nj < 0 || nj >= n || vis[ni][nj] || mp[ni][nj]=='X')continue;
bfs.push({ni,nj});
}
}
cout<<ans;
}