Submission #838777

# Submission time Handle Problem Language Result Execution time Memory
838777 2023-08-27T17:49:23 Z arbuzick Mars (APIO22_mars) C++17
36 / 100
103 ms 2924 KB
#include <bits/stdc++.h>

using namespace std;

template<typename Fun>
struct y_combinator {
    const Fun fun;
 
    explicit y_combinator(const Fun&& fun) : fun(std::forward<const Fun>(fun)) {}
 
    template<typename... Args>
    auto operator()(Args&&... args) const {
        return fun(std::ref(*this), std::forward<Args>(args)...);
    }
};

string process(vector<vector<string>> a, int i, int j, int k, int n) {
    if (k == n - 1) {
        vector<string> g(n * 2 + 1, string(n * 2 + 1, '0'));
        vector<vector<int>> used(n * 2 + 1, vector<int>(n * 2 + 1));
        for (int x = 0; x < 3; ++x) {
            for (int y = 0; y < 3; ++y) {
                int p = 0;
                for (int i = x; i < x + 3 + (k - 1) * 2; i += 2) {
                    for (int j = y; j < y + 3 + (k - 1) * 2; j += 2) {
                        g[i][j] = a[x][y][p];
                        p++;
                    }
                }
            }
        }
        int ans = 0;
        for (int x = 0; x < n * 2 + 1; ++x) {
            for (int y = 0; y < n * 2 + 1; ++y) {
                if (g[x][y] == '0' || used[x][y]) {
                    continue;
                }
				ans++;
                y_combinator([&](auto dfs, int i, int j) -> void {
                    used[i][j] = 1;
                    if (i + 1 < n * 2 + 1 && g[i + 1][j] == '1' && !used[i + 1][j]) {
                        dfs(i + 1, j);
                    }
                    if (j + 1 < n * 2 + 1 && g[i][j + 1] == '1' && !used[i][j + 1]) {
                        dfs(i, j + 1);
                    }
                    if (i && g[i - 1][j] == '1' && !used[i - 1][j]) {
                        dfs(i - 1, j);
                    }
                    if (j && g[i][j - 1] == '1' && !used[i][j - 1]) {
                        dfs(i, j - 1);
                    }
                })(x, y);
            }
        }
        string r = string(100, '0');
        for (int i = 0; i  < 20; ++i) {
            if (ans & (1 << i)) {
                r[i] = '1';
            }
        }
        return r;
    }
    vector<string> g(3 + k * 2, string(3 + k * 2, '0'));
    int kek = 0;
    for (int x = 0; x < 3; ++x) {
        for (int y = 0; y < 3; ++y) {
            int p = 0;
            for (int i = x; i < x + 3 + (k - 1) * 2; i += 2) {
                for (int j = y; j < y + 3 + (k - 1) * 2; j += 2) {
                    g[i][j] = a[x][y][p];
                    p++;
                }
            }
        }
    }
    string r = string(100, '0');
    int p = 0;
    for (int i = 0; i < 3 + k * 2; i += 2)  {
        for (int j = 0; j < 3 + k * 2; j += 2) {
            r[p] = g[i][j];
            p++;
        }
    }
    return r;
}

Compilation message

mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:65:9: warning: unused variable 'kek' [-Wunused-variable]
   65 |     int kek = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
21 Correct 38 ms 2648 KB Output is correct
22 Correct 53 ms 2732 KB Output is correct
23 Correct 49 ms 2668 KB Output is correct
24 Correct 48 ms 2756 KB Output is correct
25 Correct 52 ms 2604 KB Output is correct
26 Correct 51 ms 2608 KB Output is correct
27 Correct 51 ms 2708 KB Output is correct
28 Correct 57 ms 2724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
21 Correct 38 ms 2648 KB Output is correct
22 Correct 53 ms 2732 KB Output is correct
23 Correct 49 ms 2668 KB Output is correct
24 Correct 48 ms 2756 KB Output is correct
25 Correct 52 ms 2604 KB Output is correct
26 Correct 51 ms 2608 KB Output is correct
27 Correct 51 ms 2708 KB Output is correct
28 Correct 57 ms 2724 KB Output is correct
29 Correct 70 ms 2708 KB Output is correct
30 Correct 97 ms 2832 KB Output is correct
31 Correct 103 ms 2816 KB Output is correct
32 Correct 93 ms 2852 KB Output is correct
33 Correct 103 ms 2804 KB Output is correct
34 Correct 100 ms 2816 KB Output is correct
35 Correct 101 ms 2924 KB Output is correct
36 Correct 94 ms 2912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
21 Correct 38 ms 2648 KB Output is correct
22 Correct 53 ms 2732 KB Output is correct
23 Correct 49 ms 2668 KB Output is correct
24 Correct 48 ms 2756 KB Output is correct
25 Correct 52 ms 2604 KB Output is correct
26 Correct 51 ms 2608 KB Output is correct
27 Correct 51 ms 2708 KB Output is correct
28 Correct 57 ms 2724 KB Output is correct
29 Correct 70 ms 2708 KB Output is correct
30 Correct 97 ms 2832 KB Output is correct
31 Correct 103 ms 2816 KB Output is correct
32 Correct 93 ms 2852 KB Output is correct
33 Correct 103 ms 2804 KB Output is correct
34 Correct 100 ms 2816 KB Output is correct
35 Correct 101 ms 2924 KB Output is correct
36 Correct 94 ms 2912 KB Output is correct
37 Runtime error 20 ms 500 KB Execution killed with signal 6
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
21 Correct 38 ms 2648 KB Output is correct
22 Correct 53 ms 2732 KB Output is correct
23 Correct 49 ms 2668 KB Output is correct
24 Correct 48 ms 2756 KB Output is correct
25 Correct 52 ms 2604 KB Output is correct
26 Correct 51 ms 2608 KB Output is correct
27 Correct 51 ms 2708 KB Output is correct
28 Correct 57 ms 2724 KB Output is correct
29 Correct 70 ms 2708 KB Output is correct
30 Correct 97 ms 2832 KB Output is correct
31 Correct 103 ms 2816 KB Output is correct
32 Correct 93 ms 2852 KB Output is correct
33 Correct 103 ms 2804 KB Output is correct
34 Correct 100 ms 2816 KB Output is correct
35 Correct 101 ms 2924 KB Output is correct
36 Correct 94 ms 2912 KB Output is correct
37 Runtime error 20 ms 500 KB Execution killed with signal 6
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
21 Correct 38 ms 2648 KB Output is correct
22 Correct 53 ms 2732 KB Output is correct
23 Correct 49 ms 2668 KB Output is correct
24 Correct 48 ms 2756 KB Output is correct
25 Correct 52 ms 2604 KB Output is correct
26 Correct 51 ms 2608 KB Output is correct
27 Correct 51 ms 2708 KB Output is correct
28 Correct 57 ms 2724 KB Output is correct
29 Correct 70 ms 2708 KB Output is correct
30 Correct 97 ms 2832 KB Output is correct
31 Correct 103 ms 2816 KB Output is correct
32 Correct 93 ms 2852 KB Output is correct
33 Correct 103 ms 2804 KB Output is correct
34 Correct 100 ms 2816 KB Output is correct
35 Correct 101 ms 2924 KB Output is correct
36 Correct 94 ms 2912 KB Output is correct
37 Runtime error 20 ms 500 KB Execution killed with signal 6
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
21 Correct 38 ms 2648 KB Output is correct
22 Correct 53 ms 2732 KB Output is correct
23 Correct 49 ms 2668 KB Output is correct
24 Correct 48 ms 2756 KB Output is correct
25 Correct 52 ms 2604 KB Output is correct
26 Correct 51 ms 2608 KB Output is correct
27 Correct 51 ms 2708 KB Output is correct
28 Correct 57 ms 2724 KB Output is correct
29 Correct 70 ms 2708 KB Output is correct
30 Correct 97 ms 2832 KB Output is correct
31 Correct 103 ms 2816 KB Output is correct
32 Correct 93 ms 2852 KB Output is correct
33 Correct 103 ms 2804 KB Output is correct
34 Correct 100 ms 2816 KB Output is correct
35 Correct 101 ms 2924 KB Output is correct
36 Correct 94 ms 2912 KB Output is correct
37 Runtime error 20 ms 500 KB Execution killed with signal 6
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2192 KB Output is correct
2 Correct 4 ms 1988 KB Output is correct
3 Correct 5 ms 1964 KB Output is correct
4 Correct 5 ms 1756 KB Output is correct
5 Correct 2 ms 1956 KB Output is correct
6 Correct 4 ms 1860 KB Output is correct
7 Correct 8 ms 2052 KB Output is correct
8 Correct 9 ms 2204 KB Output is correct
9 Correct 8 ms 2204 KB Output is correct
10 Correct 16 ms 2012 KB Output is correct
11 Correct 8 ms 1856 KB Output is correct
12 Correct 8 ms 2092 KB Output is correct
13 Correct 8 ms 1928 KB Output is correct
14 Correct 16 ms 2376 KB Output is correct
15 Correct 23 ms 2516 KB Output is correct
16 Correct 23 ms 2564 KB Output is correct
17 Correct 28 ms 2536 KB Output is correct
18 Correct 23 ms 2580 KB Output is correct
19 Correct 24 ms 2600 KB Output is correct
20 Correct 27 ms 2644 KB Output is correct
21 Correct 38 ms 2648 KB Output is correct
22 Correct 53 ms 2732 KB Output is correct
23 Correct 49 ms 2668 KB Output is correct
24 Correct 48 ms 2756 KB Output is correct
25 Correct 52 ms 2604 KB Output is correct
26 Correct 51 ms 2608 KB Output is correct
27 Correct 51 ms 2708 KB Output is correct
28 Correct 57 ms 2724 KB Output is correct
29 Correct 70 ms 2708 KB Output is correct
30 Correct 97 ms 2832 KB Output is correct
31 Correct 103 ms 2816 KB Output is correct
32 Correct 93 ms 2852 KB Output is correct
33 Correct 103 ms 2804 KB Output is correct
34 Correct 100 ms 2816 KB Output is correct
35 Correct 101 ms 2924 KB Output is correct
36 Correct 94 ms 2912 KB Output is correct
37 Runtime error 20 ms 500 KB Execution killed with signal 6
38 Halted 0 ms 0 KB -