#include "mars.h"
#include <bits/stdc++.h>
using namespace std;
string process(vector<vector<string>> a, int i, int j, int k, int n) {
if (k == n - 1) {
vector<vector<int>> grid(n * 2 + 1, vector<int>(n * 2 + 1, -1));
vector<vector<bool>> flag(n * 2 + 1, vector<bool>(n * 2 + 1, false));
const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
grid[i][j] = a[i][j][0] - '0';
}
}
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
if ((x == 2 || y == 2) && (x != 0) && (y != 0)) {
for (int i = 0; i < k * 2 + 1; i++) {
grid[x + i][y + i] = a[x][y][i] - '0';
}
}
}
}
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
if ((x == 2 || y == 2) && (x == 0 || y == 0)) {
int pt = 0;
int cx = x;
int cy = y;
for (int i = k * 2 + 1; i >= 1; i--) {
for (int j = 0; j < i; j++) {
grid[cx + j][cy + j] = a[x][y][pt++] - '0';
}
if (x == 0) {
cy++;
}
if (y == 0) {
cx++;
}
}
}
}
}
int cnt = 0;
for (int i = 0; i < n * 2 + 1; i++) {
for (int j = 0; j < n * 2 + 1; 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 < n * 2 + 1 && 0 <= ny && ny < n * 2 + 1 && grid[nx][ny] && !flag[nx][ny]) {
flag[nx][ny] = true;
q.push_back({nx, ny});
}
}
}
}
}
}
string res;
while (cnt) {
res += (char)('0' + (cnt & 1));
cnt >>= 1;
}
res.resize(100, '0');
return res;
}
string res = a[0][0].substr(0, 1);
if (i == 2 * (n - k - 1) || j == 2 * (n - k - 1)) {
res += a[1][1].substr(0, 1);
res += a[2][2].substr(0, k * 2 + 1);
if (j == 0) {
res += a[1][0].substr(0, 1);
res += a[2][1].substr(0, k * 2 + 1);
res += a[2][0].substr(0, (k * 2 + 1) * (k * 2 + 2) / 2);
}
if (i == 0) {
res += a[0][1].substr(0, 1);
res += a[1][2].substr(0, k * 2 + 1);
res += a[0][2].substr(0, (k * 2 + 1) * (k * 2 + 2) / 2);
}
}
res.resize(100, '0');
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
21 |
Correct |
58 ms |
2700 KB |
Output is correct |
22 |
Incorrect |
10 ms |
328 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
21 |
Correct |
58 ms |
2700 KB |
Output is correct |
22 |
Incorrect |
10 ms |
328 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
21 |
Correct |
58 ms |
2700 KB |
Output is correct |
22 |
Incorrect |
10 ms |
328 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
21 |
Correct |
58 ms |
2700 KB |
Output is correct |
22 |
Incorrect |
10 ms |
328 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
21 |
Correct |
58 ms |
2700 KB |
Output is correct |
22 |
Incorrect |
10 ms |
328 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
21 |
Correct |
58 ms |
2700 KB |
Output is correct |
22 |
Incorrect |
10 ms |
328 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1956 KB |
Output is correct |
2 |
Correct |
6 ms |
2076 KB |
Output is correct |
3 |
Correct |
8 ms |
2224 KB |
Output is correct |
4 |
Correct |
8 ms |
1792 KB |
Output is correct |
5 |
Correct |
8 ms |
2148 KB |
Output is correct |
6 |
Correct |
8 ms |
2044 KB |
Output is correct |
7 |
Correct |
10 ms |
1772 KB |
Output is correct |
8 |
Correct |
16 ms |
1752 KB |
Output is correct |
9 |
Correct |
16 ms |
2068 KB |
Output is correct |
10 |
Correct |
16 ms |
1836 KB |
Output is correct |
11 |
Correct |
16 ms |
1892 KB |
Output is correct |
12 |
Correct |
16 ms |
1932 KB |
Output is correct |
13 |
Correct |
16 ms |
1924 KB |
Output is correct |
14 |
Correct |
27 ms |
2452 KB |
Output is correct |
15 |
Correct |
40 ms |
2524 KB |
Output is correct |
16 |
Correct |
38 ms |
2492 KB |
Output is correct |
17 |
Correct |
39 ms |
2564 KB |
Output is correct |
18 |
Correct |
39 ms |
2568 KB |
Output is correct |
19 |
Correct |
38 ms |
2428 KB |
Output is correct |
20 |
Correct |
38 ms |
2616 KB |
Output is correct |
21 |
Correct |
58 ms |
2700 KB |
Output is correct |
22 |
Incorrect |
10 ms |
328 KB |
Incorrect |
23 |
Halted |
0 ms |
0 KB |
- |