#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));
//cout << i << " " << j << " " << k << endl;
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++) {
for (int j = i & 1; j <= i; j += 2) {
grid[x + i][y + j] = a[x][y][pt++] - '0';
}
}
}
else {
int pt = 0;
for (int i = 0; i < sz - 2; i++) {
for (int j = i; 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++) {
for (int j = i & 1; j <= i; j += 2) {
res += (char)('0' + grid[i][j]);
}
}
}
else {
for (int i = 0; i < sz; i++) {
for (int j = i; 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 |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
21 |
Correct |
62 ms |
2732 KB |
Output is correct |
22 |
Correct |
87 ms |
2668 KB |
Output is correct |
23 |
Correct |
90 ms |
2872 KB |
Output is correct |
24 |
Correct |
92 ms |
2620 KB |
Output is correct |
25 |
Correct |
89 ms |
2672 KB |
Output is correct |
26 |
Correct |
90 ms |
2640 KB |
Output is correct |
27 |
Correct |
90 ms |
2676 KB |
Output is correct |
28 |
Correct |
90 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
21 |
Correct |
62 ms |
2732 KB |
Output is correct |
22 |
Correct |
87 ms |
2668 KB |
Output is correct |
23 |
Correct |
90 ms |
2872 KB |
Output is correct |
24 |
Correct |
92 ms |
2620 KB |
Output is correct |
25 |
Correct |
89 ms |
2672 KB |
Output is correct |
26 |
Correct |
90 ms |
2640 KB |
Output is correct |
27 |
Correct |
90 ms |
2676 KB |
Output is correct |
28 |
Correct |
90 ms |
2688 KB |
Output is correct |
29 |
Correct |
133 ms |
2732 KB |
Output is correct |
30 |
Correct |
173 ms |
2808 KB |
Output is correct |
31 |
Correct |
182 ms |
2920 KB |
Output is correct |
32 |
Correct |
177 ms |
2824 KB |
Output is correct |
33 |
Correct |
178 ms |
2792 KB |
Output is correct |
34 |
Correct |
180 ms |
2792 KB |
Output is correct |
35 |
Correct |
175 ms |
2804 KB |
Output is correct |
36 |
Correct |
168 ms |
2800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
21 |
Correct |
62 ms |
2732 KB |
Output is correct |
22 |
Correct |
87 ms |
2668 KB |
Output is correct |
23 |
Correct |
90 ms |
2872 KB |
Output is correct |
24 |
Correct |
92 ms |
2620 KB |
Output is correct |
25 |
Correct |
89 ms |
2672 KB |
Output is correct |
26 |
Correct |
90 ms |
2640 KB |
Output is correct |
27 |
Correct |
90 ms |
2676 KB |
Output is correct |
28 |
Correct |
90 ms |
2688 KB |
Output is correct |
29 |
Correct |
133 ms |
2732 KB |
Output is correct |
30 |
Correct |
173 ms |
2808 KB |
Output is correct |
31 |
Correct |
182 ms |
2920 KB |
Output is correct |
32 |
Correct |
177 ms |
2824 KB |
Output is correct |
33 |
Correct |
178 ms |
2792 KB |
Output is correct |
34 |
Correct |
180 ms |
2792 KB |
Output is correct |
35 |
Correct |
175 ms |
2804 KB |
Output is correct |
36 |
Correct |
168 ms |
2800 KB |
Output is correct |
37 |
Incorrect |
31 ms |
376 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
21 |
Correct |
62 ms |
2732 KB |
Output is correct |
22 |
Correct |
87 ms |
2668 KB |
Output is correct |
23 |
Correct |
90 ms |
2872 KB |
Output is correct |
24 |
Correct |
92 ms |
2620 KB |
Output is correct |
25 |
Correct |
89 ms |
2672 KB |
Output is correct |
26 |
Correct |
90 ms |
2640 KB |
Output is correct |
27 |
Correct |
90 ms |
2676 KB |
Output is correct |
28 |
Correct |
90 ms |
2688 KB |
Output is correct |
29 |
Correct |
133 ms |
2732 KB |
Output is correct |
30 |
Correct |
173 ms |
2808 KB |
Output is correct |
31 |
Correct |
182 ms |
2920 KB |
Output is correct |
32 |
Correct |
177 ms |
2824 KB |
Output is correct |
33 |
Correct |
178 ms |
2792 KB |
Output is correct |
34 |
Correct |
180 ms |
2792 KB |
Output is correct |
35 |
Correct |
175 ms |
2804 KB |
Output is correct |
36 |
Correct |
168 ms |
2800 KB |
Output is correct |
37 |
Incorrect |
31 ms |
376 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
21 |
Correct |
62 ms |
2732 KB |
Output is correct |
22 |
Correct |
87 ms |
2668 KB |
Output is correct |
23 |
Correct |
90 ms |
2872 KB |
Output is correct |
24 |
Correct |
92 ms |
2620 KB |
Output is correct |
25 |
Correct |
89 ms |
2672 KB |
Output is correct |
26 |
Correct |
90 ms |
2640 KB |
Output is correct |
27 |
Correct |
90 ms |
2676 KB |
Output is correct |
28 |
Correct |
90 ms |
2688 KB |
Output is correct |
29 |
Correct |
133 ms |
2732 KB |
Output is correct |
30 |
Correct |
173 ms |
2808 KB |
Output is correct |
31 |
Correct |
182 ms |
2920 KB |
Output is correct |
32 |
Correct |
177 ms |
2824 KB |
Output is correct |
33 |
Correct |
178 ms |
2792 KB |
Output is correct |
34 |
Correct |
180 ms |
2792 KB |
Output is correct |
35 |
Correct |
175 ms |
2804 KB |
Output is correct |
36 |
Correct |
168 ms |
2800 KB |
Output is correct |
37 |
Incorrect |
31 ms |
376 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
21 |
Correct |
62 ms |
2732 KB |
Output is correct |
22 |
Correct |
87 ms |
2668 KB |
Output is correct |
23 |
Correct |
90 ms |
2872 KB |
Output is correct |
24 |
Correct |
92 ms |
2620 KB |
Output is correct |
25 |
Correct |
89 ms |
2672 KB |
Output is correct |
26 |
Correct |
90 ms |
2640 KB |
Output is correct |
27 |
Correct |
90 ms |
2676 KB |
Output is correct |
28 |
Correct |
90 ms |
2688 KB |
Output is correct |
29 |
Correct |
133 ms |
2732 KB |
Output is correct |
30 |
Correct |
173 ms |
2808 KB |
Output is correct |
31 |
Correct |
182 ms |
2920 KB |
Output is correct |
32 |
Correct |
177 ms |
2824 KB |
Output is correct |
33 |
Correct |
178 ms |
2792 KB |
Output is correct |
34 |
Correct |
180 ms |
2792 KB |
Output is correct |
35 |
Correct |
175 ms |
2804 KB |
Output is correct |
36 |
Correct |
168 ms |
2800 KB |
Output is correct |
37 |
Incorrect |
31 ms |
376 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
2040 KB |
Output is correct |
2 |
Correct |
8 ms |
2104 KB |
Output is correct |
3 |
Correct |
8 ms |
2028 KB |
Output is correct |
4 |
Correct |
8 ms |
2052 KB |
Output is correct |
5 |
Correct |
8 ms |
1800 KB |
Output is correct |
6 |
Correct |
8 ms |
2280 KB |
Output is correct |
7 |
Correct |
9 ms |
2084 KB |
Output is correct |
8 |
Correct |
16 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2036 KB |
Output is correct |
10 |
Correct |
16 ms |
1820 KB |
Output is correct |
11 |
Correct |
16 ms |
1896 KB |
Output is correct |
12 |
Correct |
16 ms |
2204 KB |
Output is correct |
13 |
Correct |
16 ms |
2092 KB |
Output is correct |
14 |
Correct |
28 ms |
2476 KB |
Output is correct |
15 |
Correct |
41 ms |
2576 KB |
Output is correct |
16 |
Correct |
41 ms |
2520 KB |
Output is correct |
17 |
Correct |
41 ms |
2568 KB |
Output is correct |
18 |
Correct |
43 ms |
2544 KB |
Output is correct |
19 |
Correct |
41 ms |
2480 KB |
Output is correct |
20 |
Correct |
41 ms |
2524 KB |
Output is correct |
21 |
Correct |
62 ms |
2732 KB |
Output is correct |
22 |
Correct |
87 ms |
2668 KB |
Output is correct |
23 |
Correct |
90 ms |
2872 KB |
Output is correct |
24 |
Correct |
92 ms |
2620 KB |
Output is correct |
25 |
Correct |
89 ms |
2672 KB |
Output is correct |
26 |
Correct |
90 ms |
2640 KB |
Output is correct |
27 |
Correct |
90 ms |
2676 KB |
Output is correct |
28 |
Correct |
90 ms |
2688 KB |
Output is correct |
29 |
Correct |
133 ms |
2732 KB |
Output is correct |
30 |
Correct |
173 ms |
2808 KB |
Output is correct |
31 |
Correct |
182 ms |
2920 KB |
Output is correct |
32 |
Correct |
177 ms |
2824 KB |
Output is correct |
33 |
Correct |
178 ms |
2792 KB |
Output is correct |
34 |
Correct |
180 ms |
2792 KB |
Output is correct |
35 |
Correct |
175 ms |
2804 KB |
Output is correct |
36 |
Correct |
168 ms |
2800 KB |
Output is correct |
37 |
Incorrect |
31 ms |
376 KB |
Incorrect |
38 |
Halted |
0 ms |
0 KB |
- |