# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
201771 | EmmanuelAC | Emacs (COCI20_emacs) | C++14 | 5 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |