답안 #728666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
728666 2023-04-22T19:52:50 Z vjudge1 화성 (APIO22_mars) C++17
36 / 100
4000 ms 58588 KB
#include "mars.h"

#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int>> f[50][50][50];
vector<pair<int, int>> trace[50][50][50];
int g[50][50][50];
int done[50][50][50];

std::string process(std::vector<std::vector<std::string>> a, int i, int j, int k, int n) {
        k++;
        memset(done, 0, sizeof done);
        memset(g, 0, sizeof g);
        for (int ii = 0; ii <= n * 2; ii++) {
                for (int jj = 0; jj <= n * 2; jj++) {
                        trace[0][ii][jj] = {{ii, jj}};
                        g[0][ii][jj] = 1;
                }
        }

        auto fill = [&](int x, int y, int z, int a, int b) {
                f[z][x][y].clear();
                if (k == n) trace[z][x][y].clear();
                g[z][x][y] = 0;
                for (int ii = x; ii < x + 3; ii++) {
                        for (int jj = y; jj < y + 3; jj++) {
                                if (x / a != ii / b) continue;
                                if (y / a != jj / b) continue;
                                if (done[z - 1][ii][jj] == 0) {
                                        f[z][x][y].emplace_back(ii, jj);
                                        if (k == n) trace[z][x][y].insert(trace[z][x][y].end(), trace[z - 1][ii][jj].begin(), trace[z - 1][ii][jj].end());
                                        g[z][x][y] += g[z - 1][ii][jj];
                                        done[z - 1][ii][jj] = 1;
                                }
                        }
                }
        };

        for (int kk = 1; kk <= k; kk++) {
                int mm = (n - kk) * 2;
                int cur_size = mm / 3 + 1;
                int last_size = (mm + 2) / 3 + 1;
                for (int ii = 0; ii <= mm; ii++) {
                        for (int jj = 0; jj <= mm; jj++) {
                                fill(ii, jj, kk, cur_size, last_size);
                        }
                }
        }

        if (k != n) {
                string s = "";
                for (pair<int, int>& p : f[k][i][j]) {
                        int ii = p.first;
                        int jj = p.second;
                        int x = ii - i;
                        int y = jj - j;
                        for (int z = 0; z < g[k - 1][ii][jj]; z++) {
                                s += a[x][y][z];
                        }
                }
                while (s.size() < 100) s += '0';
                assert(s.size() == 100);
                return s;
        }

        k--;
        vector<vector<int>> map(n * 2 + 1, vector<int>(n * 2 + 1, 0));

        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                        for (int z = 0; z < g[k][i][j]; z++) {
                                int ii = trace[k][i][j][z].first;
                                int jj = trace[k][i][j][z].second;
                                map[ii][jj] = a[i][j][z] - '0';
                        }
                }
        }

        int dr[] = {-1, 0, +1, 0};
        int dc[] = {0, -1, 0, +1};

        int res = 0;
        for (int i = 0; i <= n * 2; i++) {
                for (int j = 0; j <= n * 2; j++) {
                        if (map[i][j] == 1) {
                                res++;
                                queue<pair<int, int>> q;
                                q.emplace(i, j);
                                map[i][j] = 0;
                                while (q.size()) {
                                        int ii = q.front().first;
                                        int jj = q.front().second;
                                        q.pop();
                                        for (int id = 0; id < 4; id++) {
                                                int ni = ii + dr[id];
                                                int nj = jj + dc[id];
                                                if (ni < 0 || nj < 0 || ni > n * 2 || nj > n * 2 || map[ni][nj] == 0) continue;
                                                q.emplace(ni, nj);
                                                map[ni][nj] = 0;
                                        }
                                }
                        }
                }
        }
        string s = "";
        while (s.size() < 100) s += res % 2 + '0', res /= 2;
        return s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
21 Correct 365 ms 57488 KB Output is correct
22 Correct 610 ms 57648 KB Output is correct
23 Correct 604 ms 57664 KB Output is correct
24 Correct 606 ms 57684 KB Output is correct
25 Correct 608 ms 57740 KB Output is correct
26 Correct 602 ms 57652 KB Output is correct
27 Correct 595 ms 57632 KB Output is correct
28 Correct 591 ms 57676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
21 Correct 365 ms 57488 KB Output is correct
22 Correct 610 ms 57648 KB Output is correct
23 Correct 604 ms 57664 KB Output is correct
24 Correct 606 ms 57684 KB Output is correct
25 Correct 608 ms 57740 KB Output is correct
26 Correct 602 ms 57652 KB Output is correct
27 Correct 595 ms 57632 KB Output is correct
28 Correct 591 ms 57676 KB Output is correct
29 Correct 1008 ms 57916 KB Output is correct
30 Correct 1645 ms 57940 KB Output is correct
31 Correct 1587 ms 57956 KB Output is correct
32 Correct 1624 ms 57952 KB Output is correct
33 Correct 1583 ms 57916 KB Output is correct
34 Correct 1600 ms 57920 KB Output is correct
35 Correct 1629 ms 57968 KB Output is correct
36 Correct 1603 ms 57912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
21 Correct 365 ms 57488 KB Output is correct
22 Correct 610 ms 57648 KB Output is correct
23 Correct 604 ms 57664 KB Output is correct
24 Correct 606 ms 57684 KB Output is correct
25 Correct 608 ms 57740 KB Output is correct
26 Correct 602 ms 57652 KB Output is correct
27 Correct 595 ms 57632 KB Output is correct
28 Correct 591 ms 57676 KB Output is correct
29 Correct 1008 ms 57916 KB Output is correct
30 Correct 1645 ms 57940 KB Output is correct
31 Correct 1587 ms 57956 KB Output is correct
32 Correct 1624 ms 57952 KB Output is correct
33 Correct 1583 ms 57916 KB Output is correct
34 Correct 1600 ms 57920 KB Output is correct
35 Correct 1629 ms 57968 KB Output is correct
36 Correct 1603 ms 57912 KB Output is correct
37 Correct 2539 ms 58312 KB Output is correct
38 Execution timed out 4000 ms 58588 KB
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
21 Correct 365 ms 57488 KB Output is correct
22 Correct 610 ms 57648 KB Output is correct
23 Correct 604 ms 57664 KB Output is correct
24 Correct 606 ms 57684 KB Output is correct
25 Correct 608 ms 57740 KB Output is correct
26 Correct 602 ms 57652 KB Output is correct
27 Correct 595 ms 57632 KB Output is correct
28 Correct 591 ms 57676 KB Output is correct
29 Correct 1008 ms 57916 KB Output is correct
30 Correct 1645 ms 57940 KB Output is correct
31 Correct 1587 ms 57956 KB Output is correct
32 Correct 1624 ms 57952 KB Output is correct
33 Correct 1583 ms 57916 KB Output is correct
34 Correct 1600 ms 57920 KB Output is correct
35 Correct 1629 ms 57968 KB Output is correct
36 Correct 1603 ms 57912 KB Output is correct
37 Correct 2539 ms 58312 KB Output is correct
38 Execution timed out 4000 ms 58588 KB
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
21 Correct 365 ms 57488 KB Output is correct
22 Correct 610 ms 57648 KB Output is correct
23 Correct 604 ms 57664 KB Output is correct
24 Correct 606 ms 57684 KB Output is correct
25 Correct 608 ms 57740 KB Output is correct
26 Correct 602 ms 57652 KB Output is correct
27 Correct 595 ms 57632 KB Output is correct
28 Correct 591 ms 57676 KB Output is correct
29 Correct 1008 ms 57916 KB Output is correct
30 Correct 1645 ms 57940 KB Output is correct
31 Correct 1587 ms 57956 KB Output is correct
32 Correct 1624 ms 57952 KB Output is correct
33 Correct 1583 ms 57916 KB Output is correct
34 Correct 1600 ms 57920 KB Output is correct
35 Correct 1629 ms 57968 KB Output is correct
36 Correct 1603 ms 57912 KB Output is correct
37 Correct 2539 ms 58312 KB Output is correct
38 Execution timed out 4000 ms 58588 KB
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
21 Correct 365 ms 57488 KB Output is correct
22 Correct 610 ms 57648 KB Output is correct
23 Correct 604 ms 57664 KB Output is correct
24 Correct 606 ms 57684 KB Output is correct
25 Correct 608 ms 57740 KB Output is correct
26 Correct 602 ms 57652 KB Output is correct
27 Correct 595 ms 57632 KB Output is correct
28 Correct 591 ms 57676 KB Output is correct
29 Correct 1008 ms 57916 KB Output is correct
30 Correct 1645 ms 57940 KB Output is correct
31 Correct 1587 ms 57956 KB Output is correct
32 Correct 1624 ms 57952 KB Output is correct
33 Correct 1583 ms 57916 KB Output is correct
34 Correct 1600 ms 57920 KB Output is correct
35 Correct 1629 ms 57968 KB Output is correct
36 Correct 1603 ms 57912 KB Output is correct
37 Correct 2539 ms 58312 KB Output is correct
38 Execution timed out 4000 ms 58588 KB
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 56720 KB Output is correct
2 Correct 52 ms 56612 KB Output is correct
3 Correct 51 ms 56828 KB Output is correct
4 Correct 49 ms 56624 KB Output is correct
5 Correct 53 ms 56680 KB Output is correct
6 Correct 48 ms 56696 KB Output is correct
7 Correct 73 ms 56656 KB Output is correct
8 Correct 93 ms 56572 KB Output is correct
9 Correct 87 ms 56688 KB Output is correct
10 Correct 88 ms 56668 KB Output is correct
11 Correct 87 ms 56716 KB Output is correct
12 Correct 88 ms 56636 KB Output is correct
13 Correct 86 ms 56616 KB Output is correct
14 Correct 157 ms 57312 KB Output is correct
15 Correct 250 ms 57372 KB Output is correct
16 Correct 244 ms 57396 KB Output is correct
17 Correct 209 ms 57404 KB Output is correct
18 Correct 212 ms 57392 KB Output is correct
19 Correct 208 ms 57388 KB Output is correct
20 Correct 219 ms 57392 KB Output is correct
21 Correct 365 ms 57488 KB Output is correct
22 Correct 610 ms 57648 KB Output is correct
23 Correct 604 ms 57664 KB Output is correct
24 Correct 606 ms 57684 KB Output is correct
25 Correct 608 ms 57740 KB Output is correct
26 Correct 602 ms 57652 KB Output is correct
27 Correct 595 ms 57632 KB Output is correct
28 Correct 591 ms 57676 KB Output is correct
29 Correct 1008 ms 57916 KB Output is correct
30 Correct 1645 ms 57940 KB Output is correct
31 Correct 1587 ms 57956 KB Output is correct
32 Correct 1624 ms 57952 KB Output is correct
33 Correct 1583 ms 57916 KB Output is correct
34 Correct 1600 ms 57920 KB Output is correct
35 Correct 1629 ms 57968 KB Output is correct
36 Correct 1603 ms 57912 KB Output is correct
37 Correct 2539 ms 58312 KB Output is correct
38 Execution timed out 4000 ms 58588 KB
39 Halted 0 ms 0 KB -