#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++) {
if (x + i > y + j) {
int pt = 0;
for (int i = 0; i < sz - 2; i += 2) {
for (int j = 0; j <= i; j += 2) {
grid[x + i][y + j] = a[x][y][pt++] - '0';
}
}
}
if (x + i < y + j) {
int pt = 0;
for (int i = 0; i < sz - 2; i += 2) {
for (int j = i; j < sz - 2; j += 2) {
grid[x + i][y + j] = a[x][y][pt++] - '0';
}
}
}
if (x + i == y + j) {
int pt = 0;
for (int i = 0; i < sz - 2; i += 2) {
for (int j = 0; j < sz - 2; j += 2) {
grid[x + i][y + j] = a[x][y][pt++] - '0';
}
}
}
}
}
string res;
if (k == n - 1) {
/* cout << '\n';
for (int i = 0; i < sz; i++) {
for (int j = 0; j < sz; j++) {
if (grid[i][j] == -1) {
cout << "?" << " ";
}
else {
cout << grid[i][j] << " ";
}
}
cout << '\n';
}
cout << '\n';*/
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 {
if (i > j) {
for (int i = 0; i < sz; i += 2) {
for (int j = 0; j <= i; j += 2) {
res += (char)('0' + grid[i][j]);
}
}
}
if (i < j) {
for (int i = 0; i < sz; i += 2) {
for (int j = i; j < sz; j += 2) {
res += (char)('0' + grid[i][j]);
}
}
}
if (i == j) {
for (int i = 0; i < sz; i += 2) {
for (int j = 0; j < sz; j += 2) {
res += (char)('0' + grid[i][j]);
}
}
}
}
res.resize(100, '0');
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
21 |
Correct |
63 ms |
2644 KB |
Output is correct |
22 |
Correct |
92 ms |
2712 KB |
Output is correct |
23 |
Correct |
92 ms |
2648 KB |
Output is correct |
24 |
Correct |
92 ms |
2676 KB |
Output is correct |
25 |
Correct |
88 ms |
2684 KB |
Output is correct |
26 |
Correct |
93 ms |
2668 KB |
Output is correct |
27 |
Correct |
100 ms |
2644 KB |
Output is correct |
28 |
Correct |
104 ms |
2664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
21 |
Correct |
63 ms |
2644 KB |
Output is correct |
22 |
Correct |
92 ms |
2712 KB |
Output is correct |
23 |
Correct |
92 ms |
2648 KB |
Output is correct |
24 |
Correct |
92 ms |
2676 KB |
Output is correct |
25 |
Correct |
88 ms |
2684 KB |
Output is correct |
26 |
Correct |
93 ms |
2668 KB |
Output is correct |
27 |
Correct |
100 ms |
2644 KB |
Output is correct |
28 |
Correct |
104 ms |
2664 KB |
Output is correct |
29 |
Correct |
131 ms |
2736 KB |
Output is correct |
30 |
Correct |
174 ms |
2812 KB |
Output is correct |
31 |
Correct |
175 ms |
2900 KB |
Output is correct |
32 |
Correct |
179 ms |
2808 KB |
Output is correct |
33 |
Correct |
181 ms |
2868 KB |
Output is correct |
34 |
Correct |
186 ms |
2936 KB |
Output is correct |
35 |
Correct |
175 ms |
2800 KB |
Output is correct |
36 |
Correct |
172 ms |
2904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
21 |
Correct |
63 ms |
2644 KB |
Output is correct |
22 |
Correct |
92 ms |
2712 KB |
Output is correct |
23 |
Correct |
92 ms |
2648 KB |
Output is correct |
24 |
Correct |
92 ms |
2676 KB |
Output is correct |
25 |
Correct |
88 ms |
2684 KB |
Output is correct |
26 |
Correct |
93 ms |
2668 KB |
Output is correct |
27 |
Correct |
100 ms |
2644 KB |
Output is correct |
28 |
Correct |
104 ms |
2664 KB |
Output is correct |
29 |
Correct |
131 ms |
2736 KB |
Output is correct |
30 |
Correct |
174 ms |
2812 KB |
Output is correct |
31 |
Correct |
175 ms |
2900 KB |
Output is correct |
32 |
Correct |
179 ms |
2808 KB |
Output is correct |
33 |
Correct |
181 ms |
2868 KB |
Output is correct |
34 |
Correct |
186 ms |
2936 KB |
Output is correct |
35 |
Correct |
175 ms |
2800 KB |
Output is correct |
36 |
Correct |
172 ms |
2904 KB |
Output is correct |
37 |
Incorrect |
29 ms |
412 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
21 |
Correct |
63 ms |
2644 KB |
Output is correct |
22 |
Correct |
92 ms |
2712 KB |
Output is correct |
23 |
Correct |
92 ms |
2648 KB |
Output is correct |
24 |
Correct |
92 ms |
2676 KB |
Output is correct |
25 |
Correct |
88 ms |
2684 KB |
Output is correct |
26 |
Correct |
93 ms |
2668 KB |
Output is correct |
27 |
Correct |
100 ms |
2644 KB |
Output is correct |
28 |
Correct |
104 ms |
2664 KB |
Output is correct |
29 |
Correct |
131 ms |
2736 KB |
Output is correct |
30 |
Correct |
174 ms |
2812 KB |
Output is correct |
31 |
Correct |
175 ms |
2900 KB |
Output is correct |
32 |
Correct |
179 ms |
2808 KB |
Output is correct |
33 |
Correct |
181 ms |
2868 KB |
Output is correct |
34 |
Correct |
186 ms |
2936 KB |
Output is correct |
35 |
Correct |
175 ms |
2800 KB |
Output is correct |
36 |
Correct |
172 ms |
2904 KB |
Output is correct |
37 |
Incorrect |
29 ms |
412 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
21 |
Correct |
63 ms |
2644 KB |
Output is correct |
22 |
Correct |
92 ms |
2712 KB |
Output is correct |
23 |
Correct |
92 ms |
2648 KB |
Output is correct |
24 |
Correct |
92 ms |
2676 KB |
Output is correct |
25 |
Correct |
88 ms |
2684 KB |
Output is correct |
26 |
Correct |
93 ms |
2668 KB |
Output is correct |
27 |
Correct |
100 ms |
2644 KB |
Output is correct |
28 |
Correct |
104 ms |
2664 KB |
Output is correct |
29 |
Correct |
131 ms |
2736 KB |
Output is correct |
30 |
Correct |
174 ms |
2812 KB |
Output is correct |
31 |
Correct |
175 ms |
2900 KB |
Output is correct |
32 |
Correct |
179 ms |
2808 KB |
Output is correct |
33 |
Correct |
181 ms |
2868 KB |
Output is correct |
34 |
Correct |
186 ms |
2936 KB |
Output is correct |
35 |
Correct |
175 ms |
2800 KB |
Output is correct |
36 |
Correct |
172 ms |
2904 KB |
Output is correct |
37 |
Incorrect |
29 ms |
412 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
21 |
Correct |
63 ms |
2644 KB |
Output is correct |
22 |
Correct |
92 ms |
2712 KB |
Output is correct |
23 |
Correct |
92 ms |
2648 KB |
Output is correct |
24 |
Correct |
92 ms |
2676 KB |
Output is correct |
25 |
Correct |
88 ms |
2684 KB |
Output is correct |
26 |
Correct |
93 ms |
2668 KB |
Output is correct |
27 |
Correct |
100 ms |
2644 KB |
Output is correct |
28 |
Correct |
104 ms |
2664 KB |
Output is correct |
29 |
Correct |
131 ms |
2736 KB |
Output is correct |
30 |
Correct |
174 ms |
2812 KB |
Output is correct |
31 |
Correct |
175 ms |
2900 KB |
Output is correct |
32 |
Correct |
179 ms |
2808 KB |
Output is correct |
33 |
Correct |
181 ms |
2868 KB |
Output is correct |
34 |
Correct |
186 ms |
2936 KB |
Output is correct |
35 |
Correct |
175 ms |
2800 KB |
Output is correct |
36 |
Correct |
172 ms |
2904 KB |
Output is correct |
37 |
Incorrect |
29 ms |
412 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
1892 KB |
Output is correct |
3 |
Correct |
8 ms |
1788 KB |
Output is correct |
4 |
Correct |
8 ms |
1732 KB |
Output is correct |
5 |
Correct |
8 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
2180 KB |
Output is correct |
7 |
Correct |
10 ms |
2048 KB |
Output is correct |
8 |
Correct |
17 ms |
1684 KB |
Output is correct |
9 |
Correct |
16 ms |
1968 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
16 ms |
2032 KB |
Output is correct |
12 |
Correct |
16 ms |
1956 KB |
Output is correct |
13 |
Correct |
16 ms |
2044 KB |
Output is correct |
14 |
Correct |
28 ms |
2372 KB |
Output is correct |
15 |
Correct |
41 ms |
2544 KB |
Output is correct |
16 |
Correct |
43 ms |
2584 KB |
Output is correct |
17 |
Correct |
44 ms |
2580 KB |
Output is correct |
18 |
Correct |
40 ms |
2632 KB |
Output is correct |
19 |
Correct |
40 ms |
2524 KB |
Output is correct |
20 |
Correct |
43 ms |
2568 KB |
Output is correct |
21 |
Correct |
63 ms |
2644 KB |
Output is correct |
22 |
Correct |
92 ms |
2712 KB |
Output is correct |
23 |
Correct |
92 ms |
2648 KB |
Output is correct |
24 |
Correct |
92 ms |
2676 KB |
Output is correct |
25 |
Correct |
88 ms |
2684 KB |
Output is correct |
26 |
Correct |
93 ms |
2668 KB |
Output is correct |
27 |
Correct |
100 ms |
2644 KB |
Output is correct |
28 |
Correct |
104 ms |
2664 KB |
Output is correct |
29 |
Correct |
131 ms |
2736 KB |
Output is correct |
30 |
Correct |
174 ms |
2812 KB |
Output is correct |
31 |
Correct |
175 ms |
2900 KB |
Output is correct |
32 |
Correct |
179 ms |
2808 KB |
Output is correct |
33 |
Correct |
181 ms |
2868 KB |
Output is correct |
34 |
Correct |
186 ms |
2936 KB |
Output is correct |
35 |
Correct |
175 ms |
2800 KB |
Output is correct |
36 |
Correct |
172 ms |
2904 KB |
Output is correct |
37 |
Incorrect |
29 ms |
412 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |