| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 300033 | ryuku1110 | Emacs (COCI20_emacs) | C++14 | 2 ms | 896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
int n, m, cnt = 0;
char x[101][101];
vector < pair<int, int > > adj[101][101];
bool visit[101][101];
void dfs(int x, int y) {
visit[x][y] = true;
for (auto v : adj[x][y]) {
if (visit[v.fi][v.se]) continue;
dfs(v.fi, v.se);
}
}
int main() {
//freopen(".INP", "r", stdin);
//freopen(".OUT", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> m;
for (int i = 1; i <= n; ++ i) {
for (int j = 1; j <= m; ++ j) {
cin >> x[i][j];
if (x[i][j] == '*') {
if (x[i-1][j] == '*') {
adj[i][j].pb({i-1, j});
adj[i-1][j].pb({i, j});
}
if (x[i][j-1] == '*') {
adj[i][j].pb({i, j-1});
adj[i][j-1].pb({i, j});
}
}
}
}
for (int i = 1; i <= n; ++ i) {
for (int j = 1; j <= m; ++ j) {
if (x[i][j] == '*' && visit[i][j] == false) {
++ cnt;
dfs(i, j);
}
}
}
cout << cnt;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
