답안 #201771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201771 2020-02-12T01:16:58 Z EmmanuelAC Emacs (COCI20_emacs) C++14
50 / 50
5 ms 380 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

int n,m,ans;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
char mdo[110][110];

void dfs( int f , int c ){
    mdo[f][c] = '.';
    for(int k=0; k<4; k++){
        if( f+dy[k]>=0 && f+dy[k]<n && c+dx[k]>=0 && c+dx[k]<m && mdo[ f+dy[k] ][ c+dx[k] ]=='*' ) dfs( f+dy[k] , c+dx[k]  );
    }
    return;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >> mdo[i][j];

    for(int i=0; i<n; i++) for(int j=0; j<m; j++){
        if( mdo[i][j]=='*' ){
            ans++;
            dfs( i , j );
        }
    }

    cout << ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct