Submission #74284192


Source Code Expand

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll=long long;
using ull= unsigned long long;
const int inf=INT_MIN/2;
const ll mod=998244353;
void a()
{
    int n;
    cin >>n;
    for(int i=n;i>=2;i--) {
        cout <<i<<",";
    }
    cout <<1<<endl;
}
void b() {
    int n;
    cin >>n;
    vector<vector<ll>> cc(n+1,vector<ll>(n+1));
    for(int i=1;i<=n;i++) {
        for(int j=i+1;j<=n;j++) {
            cin >>cc[i][j];
        }
    }

    for(int a=1;a<=n;a++) {
        for(int b=a+1;b<=n;b++) {
            for(int c=b+1;c<=n;c++) {
                if(cc[a][b]+cc[b][c]<cc[a][c]) {
                    cout <<"Yes"<<endl;
                    return ;
                }
            }
        }
    }
    cout <<"No"<<endl;
}
void c() {
    int n,m;
    cin >>n>>m;
    vector<string> map(n);
    for(auto & x : map) cin >>x;
    auto inside=[&](int x,int y) {
        return x>=0&&x<n&&y>=0&&y<m;
    };
    vector<pair<int,int>> dir={
        {0,-1},{0,1},{-1,0},{1,0}
    };
    int ans=0;
    auto dfs=[&](auto &self,int sx,int sy,int &flag) -> void {
        for(auto &[dx,dy] : dir) {
            int tx=dx+sx,ty=dy+sy;
            if(!inside(tx,ty)) {
                flag=0;
                continue;
            }
            if(map[tx][ty]=='#') continue;
            map[tx][ty]='#';
            self(self,tx,ty,flag);
        }
    };

    for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
            if(map[i][j]!='#') {
                int flag=1;
                dfs(dfs,i,j,flag);
                ans+=flag;
            }
        }
    }
    cout <<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // int n;
    // cin >>n;
    // for(int i=0;i<n;i++)
    c();

}

Submission Info

Submission Time
Task C - Puddles
User Li_x
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1842 Byte
Status AC
Exec Time 40 ms
Memory 59392 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 3640 KiB
random_01.txt AC 8 ms 4644 KiB
random_02.txt AC 3 ms 3804 KiB
random_03.txt AC 8 ms 4712 KiB
random_04.txt AC 4 ms 4120 KiB
random_05.txt AC 13 ms 4580 KiB
random_06.txt AC 1 ms 3592 KiB
random_07.txt AC 13 ms 4560 KiB
random_08.txt AC 2 ms 3560 KiB
random_09.txt AC 18 ms 5736 KiB
random_10.txt AC 13 ms 5340 KiB
random_11.txt AC 18 ms 6584 KiB
random_12.txt AC 1 ms 3716 KiB
random_13.txt AC 29 ms 26596 KiB
random_14.txt AC 3 ms 5056 KiB
random_15.txt AC 29 ms 26880 KiB
random_16.txt AC 10 ms 10648 KiB
random_17.txt AC 3 ms 4632 KiB
random_18.txt AC 40 ms 59392 KiB
random_19.txt AC 6 ms 4644 KiB
random_20.txt AC 21 ms 31876 KiB
random_21.txt AC 20 ms 31736 KiB
sample_01.txt AC 1 ms 3540 KiB
sample_02.txt AC 1 ms 3440 KiB