# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930404 | Whisper | Emacs (COCI20_emacs) | C++17 | 1 ms | 1628 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |