Submission #728664

# Submission time Handle Problem Language Result Execution time Memory
728664 2023-04-22T19:49:28 Z vjudge1 Mars (APIO22_mars) C++17
44 / 100
4000 ms 59040 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();
                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);
                                        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;
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
21 Correct 347 ms 57536 KB Output is correct
22 Correct 576 ms 57676 KB Output is correct
23 Correct 571 ms 57700 KB Output is correct
24 Correct 584 ms 57692 KB Output is correct
25 Correct 590 ms 57784 KB Output is correct
26 Correct 581 ms 57704 KB Output is correct
27 Correct 577 ms 57672 KB Output is correct
28 Correct 570 ms 57700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
21 Correct 347 ms 57536 KB Output is correct
22 Correct 576 ms 57676 KB Output is correct
23 Correct 571 ms 57700 KB Output is correct
24 Correct 584 ms 57692 KB Output is correct
25 Correct 590 ms 57784 KB Output is correct
26 Correct 581 ms 57704 KB Output is correct
27 Correct 577 ms 57672 KB Output is correct
28 Correct 570 ms 57700 KB Output is correct
29 Correct 982 ms 57952 KB Output is correct
30 Correct 1562 ms 58088 KB Output is correct
31 Correct 1551 ms 58172 KB Output is correct
32 Correct 1587 ms 58244 KB Output is correct
33 Correct 1580 ms 58180 KB Output is correct
34 Correct 1573 ms 58196 KB Output is correct
35 Correct 1601 ms 58156 KB Output is correct
36 Correct 1599 ms 58116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
21 Correct 347 ms 57536 KB Output is correct
22 Correct 576 ms 57676 KB Output is correct
23 Correct 571 ms 57700 KB Output is correct
24 Correct 584 ms 57692 KB Output is correct
25 Correct 590 ms 57784 KB Output is correct
26 Correct 581 ms 57704 KB Output is correct
27 Correct 577 ms 57672 KB Output is correct
28 Correct 570 ms 57700 KB Output is correct
29 Correct 982 ms 57952 KB Output is correct
30 Correct 1562 ms 58088 KB Output is correct
31 Correct 1551 ms 58172 KB Output is correct
32 Correct 1587 ms 58244 KB Output is correct
33 Correct 1580 ms 58180 KB Output is correct
34 Correct 1573 ms 58196 KB Output is correct
35 Correct 1601 ms 58156 KB Output is correct
36 Correct 1599 ms 58116 KB Output is correct
37 Correct 2496 ms 58376 KB Output is correct
38 Correct 3832 ms 58896 KB Output is correct
39 Correct 3947 ms 58904 KB Output is correct
40 Correct 3865 ms 58904 KB Output is correct
41 Correct 3899 ms 58892 KB Output is correct
42 Correct 3899 ms 58780 KB Output is correct
43 Correct 3882 ms 58776 KB Output is correct
44 Correct 3928 ms 58744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
21 Correct 347 ms 57536 KB Output is correct
22 Correct 576 ms 57676 KB Output is correct
23 Correct 571 ms 57700 KB Output is correct
24 Correct 584 ms 57692 KB Output is correct
25 Correct 590 ms 57784 KB Output is correct
26 Correct 581 ms 57704 KB Output is correct
27 Correct 577 ms 57672 KB Output is correct
28 Correct 570 ms 57700 KB Output is correct
29 Correct 982 ms 57952 KB Output is correct
30 Correct 1562 ms 58088 KB Output is correct
31 Correct 1551 ms 58172 KB Output is correct
32 Correct 1587 ms 58244 KB Output is correct
33 Correct 1580 ms 58180 KB Output is correct
34 Correct 1573 ms 58196 KB Output is correct
35 Correct 1601 ms 58156 KB Output is correct
36 Correct 1599 ms 58116 KB Output is correct
37 Correct 2496 ms 58376 KB Output is correct
38 Correct 3832 ms 58896 KB Output is correct
39 Correct 3947 ms 58904 KB Output is correct
40 Correct 3865 ms 58904 KB Output is correct
41 Correct 3899 ms 58892 KB Output is correct
42 Correct 3899 ms 58780 KB Output is correct
43 Correct 3882 ms 58776 KB Output is correct
44 Correct 3928 ms 58744 KB Output is correct
45 Execution timed out 4000 ms 59040 KB
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
21 Correct 347 ms 57536 KB Output is correct
22 Correct 576 ms 57676 KB Output is correct
23 Correct 571 ms 57700 KB Output is correct
24 Correct 584 ms 57692 KB Output is correct
25 Correct 590 ms 57784 KB Output is correct
26 Correct 581 ms 57704 KB Output is correct
27 Correct 577 ms 57672 KB Output is correct
28 Correct 570 ms 57700 KB Output is correct
29 Correct 982 ms 57952 KB Output is correct
30 Correct 1562 ms 58088 KB Output is correct
31 Correct 1551 ms 58172 KB Output is correct
32 Correct 1587 ms 58244 KB Output is correct
33 Correct 1580 ms 58180 KB Output is correct
34 Correct 1573 ms 58196 KB Output is correct
35 Correct 1601 ms 58156 KB Output is correct
36 Correct 1599 ms 58116 KB Output is correct
37 Correct 2496 ms 58376 KB Output is correct
38 Correct 3832 ms 58896 KB Output is correct
39 Correct 3947 ms 58904 KB Output is correct
40 Correct 3865 ms 58904 KB Output is correct
41 Correct 3899 ms 58892 KB Output is correct
42 Correct 3899 ms 58780 KB Output is correct
43 Correct 3882 ms 58776 KB Output is correct
44 Correct 3928 ms 58744 KB Output is correct
45 Execution timed out 4000 ms 59040 KB
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
21 Correct 347 ms 57536 KB Output is correct
22 Correct 576 ms 57676 KB Output is correct
23 Correct 571 ms 57700 KB Output is correct
24 Correct 584 ms 57692 KB Output is correct
25 Correct 590 ms 57784 KB Output is correct
26 Correct 581 ms 57704 KB Output is correct
27 Correct 577 ms 57672 KB Output is correct
28 Correct 570 ms 57700 KB Output is correct
29 Correct 982 ms 57952 KB Output is correct
30 Correct 1562 ms 58088 KB Output is correct
31 Correct 1551 ms 58172 KB Output is correct
32 Correct 1587 ms 58244 KB Output is correct
33 Correct 1580 ms 58180 KB Output is correct
34 Correct 1573 ms 58196 KB Output is correct
35 Correct 1601 ms 58156 KB Output is correct
36 Correct 1599 ms 58116 KB Output is correct
37 Correct 2496 ms 58376 KB Output is correct
38 Correct 3832 ms 58896 KB Output is correct
39 Correct 3947 ms 58904 KB Output is correct
40 Correct 3865 ms 58904 KB Output is correct
41 Correct 3899 ms 58892 KB Output is correct
42 Correct 3899 ms 58780 KB Output is correct
43 Correct 3882 ms 58776 KB Output is correct
44 Correct 3928 ms 58744 KB Output is correct
45 Execution timed out 4000 ms 59040 KB
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 56772 KB Output is correct
2 Correct 52 ms 56748 KB Output is correct
3 Correct 49 ms 56652 KB Output is correct
4 Correct 46 ms 56664 KB Output is correct
5 Correct 48 ms 56528 KB Output is correct
6 Correct 49 ms 56580 KB Output is correct
7 Correct 70 ms 56876 KB Output is correct
8 Correct 82 ms 56596 KB Output is correct
9 Correct 82 ms 56684 KB Output is correct
10 Correct 77 ms 56748 KB Output is correct
11 Correct 76 ms 56536 KB Output is correct
12 Correct 84 ms 56480 KB Output is correct
13 Correct 80 ms 56572 KB Output is correct
14 Correct 139 ms 57372 KB Output is correct
15 Correct 205 ms 57364 KB Output is correct
16 Correct 215 ms 57456 KB Output is correct
17 Correct 210 ms 57428 KB Output is correct
18 Correct 204 ms 57432 KB Output is correct
19 Correct 203 ms 57580 KB Output is correct
20 Correct 197 ms 57416 KB Output is correct
21 Correct 347 ms 57536 KB Output is correct
22 Correct 576 ms 57676 KB Output is correct
23 Correct 571 ms 57700 KB Output is correct
24 Correct 584 ms 57692 KB Output is correct
25 Correct 590 ms 57784 KB Output is correct
26 Correct 581 ms 57704 KB Output is correct
27 Correct 577 ms 57672 KB Output is correct
28 Correct 570 ms 57700 KB Output is correct
29 Correct 982 ms 57952 KB Output is correct
30 Correct 1562 ms 58088 KB Output is correct
31 Correct 1551 ms 58172 KB Output is correct
32 Correct 1587 ms 58244 KB Output is correct
33 Correct 1580 ms 58180 KB Output is correct
34 Correct 1573 ms 58196 KB Output is correct
35 Correct 1601 ms 58156 KB Output is correct
36 Correct 1599 ms 58116 KB Output is correct
37 Correct 2496 ms 58376 KB Output is correct
38 Correct 3832 ms 58896 KB Output is correct
39 Correct 3947 ms 58904 KB Output is correct
40 Correct 3865 ms 58904 KB Output is correct
41 Correct 3899 ms 58892 KB Output is correct
42 Correct 3899 ms 58780 KB Output is correct
43 Correct 3882 ms 58776 KB Output is correct
44 Correct 3928 ms 58744 KB Output is correct
45 Execution timed out 4000 ms 59040 KB
46 Halted 0 ms 0 KB -