# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
640201 | iee | Emacs (COCI20_emacs) | C++17 | 1 ms | 596 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
char c[N][N];
int vis[N][N], n, m;
const int nxt[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
void dfs(int x, int y) {
if (vis[x][y] || c[x][y] != '*')
return;
vis[x][y] = 1;
for (int d = 0; d < 4; ++d) {
int dx = x + nxt[d][0], dy = y + nxt[d][1];
if (dx < 1 || dy < 1 || dx > n || dy > m) continue;
dfs(dx, dy);
}
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; ++i)
cin >> c[i] + 1;
int tot = 0;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j)
if (!vis[i][j] && c[i][j] == '*')
++tot, dfs(i, j);
cout << tot;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |