Submission #74308178


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
char c;
bool f[1005][1005];
short n,m,wx[4]={0,0,-1,1},wy[4]={-1,1,0,0};
int ans=0;
struct xy{
    short x,y;
};
int bfs(short sx,short sy){
    queue<xy> x;
    bool ff=1;
    x.push({sx,sy});
    f[sx][sy]=1;
    while(x.size()){
        short nx=x.front().x,ny=x.front().y;
        x.pop();
        for(short i=0;i<4;i++){
            short xx=nx+wx[i],yy=ny+wy[i];
            if(xx<1||xx>n||yy<1||yy>m){
                ff=0;
                continue;
            }else if(f[xx][yy])  continue;
            x.push({xx,yy});
            f[xx][yy]=1;
        }
    }
    return ff?1:0;
}
signed main(){
    cin>>n>>m;
    for(short i=1;i<=n;i++)  for(short j=1;j<=m;j++){
        cin>>c;
        f[i][j]=(c=='#');
    }
    for(short i=2;i<n;i++)  for(short j=2;j<m;j++)  if(!f[i][j])  ans+=bfs(i,j);
    cout<<ans;
}

Submission Info

Submission Time
Task C - Puddles
User Caigezin
Language C++23 (GCC 15.2.0)
Score 300
Code Size 902 Byte
Status AC
Exec Time 40 ms
Memory 4676 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
min.txt AC 1 ms 3652 KiB
random_01.txt AC 34 ms 4612 KiB
random_02.txt AC 11 ms 3808 KiB
random_03.txt AC 34 ms 4616 KiB
random_04.txt AC 17 ms 4216 KiB
random_05.txt AC 38 ms 4628 KiB
random_06.txt AC 2 ms 3620 KiB
random_07.txt AC 38 ms 4644 KiB
random_08.txt AC 3 ms 3616 KiB
random_09.txt AC 40 ms 4516 KiB
random_10.txt AC 29 ms 4612 KiB
random_11.txt AC 39 ms 4588 KiB
random_12.txt AC 1 ms 3548 KiB
random_13.txt AC 39 ms 4676 KiB
random_14.txt AC 4 ms 4132 KiB
random_15.txt AC 40 ms 4448 KiB
random_16.txt AC 13 ms 4164 KiB
random_17.txt AC 28 ms 4624 KiB
random_18.txt AC 38 ms 4516 KiB
random_19.txt AC 38 ms 4612 KiB
random_20.txt AC 33 ms 4516 KiB
random_21.txt AC 34 ms 4636 KiB
sample_01.txt AC 1 ms 3584 KiB
sample_02.txt AC 1 ms 3596 KiB