# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
300033 |
2020-09-16T07:33:53 Z |
ryuku1110 |
Emacs (COCI20_emacs) |
C++14 |
|
2 ms |
896 KB |
#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 |
1 |
Correct |
1 ms |
640 KB |
Output is correct |
2 |
Correct |
2 ms |
896 KB |
Output is correct |
3 |
Correct |
1 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
640 KB |
Output is correct |
6 |
Correct |
1 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
768 KB |
Output is correct |
8 |
Correct |
2 ms |
896 KB |
Output is correct |
9 |
Correct |
2 ms |
896 KB |
Output is correct |
10 |
Correct |
2 ms |
768 KB |
Output is correct |