Submission #731008

# Submission time Handle Problem Language Result Execution time Memory
731008 2023-04-26T19:08:38 Z vjudge1 Emacs (COCI20_emacs) C++17
50 / 50
1 ms 468 KB
//Test case unutma ve reset
//Sinirlari kontrol et
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1e9+7
#define OYY 1e12
#define ordu ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mid (start+end)/2
int vis[105][105];
char dizi[105][105];
int n,m;

void dfs(int i,int j){
    vis[i][j]=1;
    if(i+1<n && vis[i+1][j]==0){
        if(dizi[i+1][j]=='*'){
            dfs(i+1,j);
        }
    }
    if(j+1<m && vis[i][j+1]==0){
        if(dizi[i][j+1]=='*'){
            dfs(i,j+1);
        }
    }
    if(i-1>=0 && vis[i-1][j]==0){
        if(dizi[i-1][j]=='*'){
            dfs(i-1,j);
        }
    }
    if(j-1>=0 && vis[i][j-1]==0){
        if(dizi[i][j-1]=='*'){
            dfs(i,j-1);
        }
    }
    return ;
}

int32_t main(){
    ordu
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>dizi[i][j];
        }
    }
    int cev=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dizi[i][j]=='*' && vis[i][j]==0){
                cev++;
                dfs(i,j);
            }
        }
    }
    cout<<cev<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct