# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
930404 |
2024-02-19T14:46:18 Z |
Whisper |
Emacs (COCI20_emacs) |
C++17 |
|
1 ms |
1628 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using str = string;
const ll dx[4] = {-1, 0, 0, 1};
const ll dy[4] = {0, -1, 1, 0};
const ll dx1[8] = {-1, -1, 1, 1, 0, 0, -1, 1};
const ll dy1[8] = {-1, 1, -1, 1, -1, 1, 0, 0};
const ll N = 1e6 + 5;
const ll inf = (1e9 + 5);
const ll MOD = 1e9 + 7;
char a[1001][1001];
bool visited[1001][1001];
ll n, m;
ll cnt = 0;
void DFS( ll i , ll j ){
visited[i][j] = true;
for (int k = 0; k < 8; k++ ){
ll i1 = i + dx1[k];
ll j1 = j + dy1[k];
if ( !visited[i1][j1] && i1 >= 1 && i1 <= n && j1 >= 1 && j1 <= m && a[i1][j1] != '.'){
DFS(i1, j1);
}
}
}
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n ; i++ ){
for ( int j = 1 ; j <= m ; j++ ){
cin >> a[i][j];
}
}
memset(visited, false, sizeof(visited));
for (int i = 1; i <= n; i++ ){
for (int j = 1; j <= m ; j++ ){
if ( !visited[i][j] && a[i][j] == '*'){
++cnt;
DFS(i, j);
}
}
}
cout << cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1368 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1372 KB |
Output is correct |
5 |
Correct |
1 ms |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |