제출 #238061

#제출 시각아이디문제언어결과실행 시간메모리
238061Haunted_CppEmacs (COCI20_emacs)C++17
50 / 50
6 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 5; char g [N][N]; const int dr[] = {+1, -1, +0, +0}; const int dc[] = {+0, +0, -1, +1}; int r, c, res = 0; void dfs (int linha, int coluna) { if (linha < 0 || linha >= r || coluna < 0 || coluna >= c) return; if (g[linha][coluna] == '.') return; g[linha][coluna] = '.'; for (int i = 0; i < 4; i++) dfs (linha + dr[i], coluna + dc[i]); } int main () { ios::sync_with_stdio(0); cin.tie(0); cin >> r >> c; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> g[i][j]; } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { if (g[i][j] == '*') { ++res; dfs (i, j); } } } cout << res << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...