# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
201039 |
2020-02-09T07:19:19 Z |
gs14004 |
Emacs (COCI20_emacs) |
C++17 |
|
6 ms |
376 KB |
#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 |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
352 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |