# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
329732 |
2020-11-22T08:59:29 Z |
aris12345678 |
Zoo (COCI19_zoo) |
C++14 |
|
1 ms |
748 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<int, int>
#define fi first
#define se second
const int mxN = 1e4+5;
const int mod = 1e9+7;
const ll inf = 1e18;
int n, m, di[4] = {1, -1, 0, 0}, dj[4] = {0, 0, 1, -1};
string s[mxN];
bool vis[mxN][mxN];
bool is(int i, int j, char c) { return i >= 0 && j >= 0 && i < n && j < m && s[i][j] != '*' && s[i][j] == c && !vis[i][j]; }
void dfs(int i, int j, char c) {
vis[i][j] = 1;
for(int k = 0; k < 4; k++) {
for(int l = 0; l < 4; l++) {
if(is(di[k]+i, dj[l]+j, s[i][j])) dfs(di[k]+i, dj[l]+j, s[i][j]);
}
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> s[i];
int ans = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(is(i, j, s[i][j])) { ++ans; dfs(i, j, s[i][j]); }
}
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |