#include "mars.h"
#include <bits/stdc++.h>
using namespace std;
string process(vector<vector<string>> a, int i, int j, int k, int n) {
int sz = (k + 1) * 2 + 1;
vector<vector<int>> grid(sz, vector<int>(sz, -1));
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
int pt = 0;
for (int i = 0; i < sz - 2; i++) {
for (int j = i & 1; j < sz - 2; j += 2) {
grid[x + i][y + j] = a[x][y][pt++] - '0';
}
}
}
}
string res;
if (k == n - 1) {
vector<vector<bool>> flag(sz, vector<bool>(sz, false));
const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};
int cnt = 0;
for (int i = 0; i < sz; i++) {
for (int j = 0; j < sz; j++) {
if (!flag[i][j] && grid[i][j]) {
cnt++;
flag[i][j] = true;
deque<pair<int, int>> q = {{i, j}};
while (!q.empty()) {
int cx = q.front().first;
int cy = q.front().second;
q.pop_front();
for (int d = 0; d < 4; d++) {
int nx = cx + dx[d];
int ny = cy + dy[d];
if (0 <= nx && nx < sz && 0 <= ny && ny < sz && grid[nx][ny] && !flag[nx][ny]) {
flag[nx][ny] = true;
q.push_back({nx, ny});
}
}
}
}
}
}
while (cnt) {
res += (char)('0' + (cnt & 1));
cnt >>= 1;
}
}
else {
for (int i = 0; i < sz; i++) {
for (int j = i & 1; j < sz; j += 2) {
res += (char)('0' + grid[i][j]);
}
}
}
res.resize(100, '0');
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
21 |
Correct |
69 ms |
2544 KB |
Output is correct |
22 |
Incorrect |
13 ms |
332 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
21 |
Correct |
69 ms |
2544 KB |
Output is correct |
22 |
Incorrect |
13 ms |
332 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
21 |
Correct |
69 ms |
2544 KB |
Output is correct |
22 |
Incorrect |
13 ms |
332 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
21 |
Correct |
69 ms |
2544 KB |
Output is correct |
22 |
Incorrect |
13 ms |
332 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
21 |
Correct |
69 ms |
2544 KB |
Output is correct |
22 |
Incorrect |
13 ms |
332 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
21 |
Correct |
69 ms |
2544 KB |
Output is correct |
22 |
Incorrect |
13 ms |
332 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2004 KB |
Output is correct |
2 |
Correct |
8 ms |
2160 KB |
Output is correct |
3 |
Correct |
8 ms |
2000 KB |
Output is correct |
4 |
Correct |
8 ms |
1780 KB |
Output is correct |
5 |
Correct |
7 ms |
1964 KB |
Output is correct |
6 |
Correct |
8 ms |
2140 KB |
Output is correct |
7 |
Correct |
11 ms |
1788 KB |
Output is correct |
8 |
Correct |
16 ms |
1892 KB |
Output is correct |
9 |
Correct |
17 ms |
1828 KB |
Output is correct |
10 |
Correct |
19 ms |
1964 KB |
Output is correct |
11 |
Correct |
16 ms |
1928 KB |
Output is correct |
12 |
Correct |
16 ms |
2060 KB |
Output is correct |
13 |
Correct |
16 ms |
1952 KB |
Output is correct |
14 |
Correct |
31 ms |
2468 KB |
Output is correct |
15 |
Correct |
44 ms |
2596 KB |
Output is correct |
16 |
Correct |
47 ms |
2520 KB |
Output is correct |
17 |
Correct |
44 ms |
2472 KB |
Output is correct |
18 |
Correct |
44 ms |
2540 KB |
Output is correct |
19 |
Correct |
43 ms |
2560 KB |
Output is correct |
20 |
Correct |
44 ms |
2428 KB |
Output is correct |
21 |
Correct |
69 ms |
2544 KB |
Output is correct |
22 |
Incorrect |
13 ms |
332 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |