# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
346979 |
2021-01-11T13:28:53 Z |
Nursik |
Zoo (COCI19_zoo) |
C++14 |
|
1 ms |
384 KB |
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define ld long double
#define fi first
#define se second
using namespace std;
void data() {
#ifdef NURS
freopen("main.in", "r", stdin);
freopen("main.out", "w", stdout);
#endif
}
void win()
{
ios_base::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
}
int block = 400;
const ld eps = 1e-7;
const int N = 3e5 + 500;
const int mod = 1e9 + 7;
const int mod2 = 998244353;
const ll hh = 29;
const ll hh2 = 31;
int n, m;
char a[2000][2000];
bool was[2000][2000];
bool check(int x, int y, int x2, int y2)
{
if (was[x][y] || a[x][y] != a[x2][y2] || x < 0 || x > n || y < 0 || y > m)
return 0;
return 1;
}
void dfs(int x, int y)
{
was[x][y] = 1;
if (check(x + 1, y, x, y))
dfs(x + 1, y);
if (check(x - 1, y, x, y))
dfs(x - 1, y);
if (check(x, y + 1, x, y))
dfs(x, y + 1);
if (check(x, y - 1, x , y))
dfs(x, y - 1);
}
main()
{
data();
win();
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cin >> a[i][j];
}
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (!was[i][j] && a[i][j] != '*')
{
dfs(i, j);
ans++;
}
}
}
cout << ans;
}
/*
Если я солью, то я обязательно затащю
*/
Compilation message
zoo.cpp:57:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
57 | main()
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |