# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
445553 |
2021-07-18T16:31:21 Z |
ACE_ |
Zoo (COCI19_zoo) |
C++14 |
|
115 ms |
7268 KB |
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 1005;
int t, fix[N][N], n, m;
char a[N][N];
vector<pair<int, int> > next1, cur;
bool ok(int i, int j) {
if (min(i, j) < 1 || i > n || j > m) return 0;
return 1;
}
void dfs(int i, int j, char c) {
if (!ok(i, j) || a[i][j] != c || fix[i][j]) return;
fix[i][j] = 1;
next1.push_back({ i,j });
dfs(i + 1, j, c);
dfs(i - 1, j, c);
dfs(i, j - 1, c);
dfs(i, j + 1, c);
}
main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
dfs(1, 1, a[1][1]);
cur = next1;
next1.clear();
char c = a[1][1];
int ans = 0;
while (cur.size()) {
ans++;
c = 'T' + 'B' - c;
for (int k = 0; k < cur.size(); k++) {
int i = cur[k].f, j = cur[k].s;
dfs(i + 1, j, c);
dfs(i - 1, j, c);
dfs(i, j - 1, c);
dfs(i, j + 1, c);
}
cur = next1;
next1.clear();
}
cout << ans;
}
Compilation message
zoo.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main() {
| ^~~~
zoo.cpp: In function 'int main()':
zoo.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int k = 0; k < cur.size(); k++) {
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
2 ms |
844 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
2 ms |
716 KB |
Output is correct |
10 |
Correct |
2 ms |
716 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
716 KB |
Output is correct |
13 |
Correct |
2 ms |
688 KB |
Output is correct |
14 |
Correct |
2 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
2 ms |
844 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
2 ms |
716 KB |
Output is correct |
9 |
Correct |
2 ms |
716 KB |
Output is correct |
10 |
Correct |
2 ms |
716 KB |
Output is correct |
11 |
Correct |
2 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
716 KB |
Output is correct |
13 |
Correct |
2 ms |
688 KB |
Output is correct |
14 |
Correct |
2 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
716 KB |
Output is correct |
16 |
Correct |
70 ms |
7212 KB |
Output is correct |
17 |
Correct |
66 ms |
7236 KB |
Output is correct |
18 |
Correct |
68 ms |
7232 KB |
Output is correct |
19 |
Correct |
70 ms |
7268 KB |
Output is correct |
20 |
Correct |
65 ms |
7228 KB |
Output is correct |
21 |
Correct |
104 ms |
6084 KB |
Output is correct |
22 |
Correct |
104 ms |
6064 KB |
Output is correct |
23 |
Correct |
105 ms |
6144 KB |
Output is correct |
24 |
Correct |
112 ms |
6528 KB |
Output is correct |
25 |
Correct |
111 ms |
6224 KB |
Output is correct |
26 |
Correct |
108 ms |
6016 KB |
Output is correct |
27 |
Correct |
106 ms |
6100 KB |
Output is correct |
28 |
Correct |
110 ms |
6084 KB |
Output is correct |
29 |
Correct |
115 ms |
6340 KB |
Output is correct |
30 |
Correct |
112 ms |
6124 KB |
Output is correct |