# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
201039 | gs14004 | Emacs (COCI20_emacs) | C++17 | 6 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 105;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int n, m;
char str[MAXN][MAXN];
bool ok(int x, int y){
return x >= 0 && x < n && y >= 0 && y < m && str[x][y] == '*';
}
void dfs(int x, int y){
str[x][y] = '.';
for(int i=0; i<4; i++){
if(ok(x + dx[i], y + dy[i])){
dfs(x + dx[i], y + dy[i]);
}
}
}
int main(){
cin >> n >> m;
for(int i=0; i<n; i++) cin >> str[i];
int cnt = 0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(str[i][j] == '*'){
dfs(i, j);
cnt++;
}
}
}
cout << cnt << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |