답안 #741955

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741955 2023-05-15T07:58:24 Z t6twotwo 화성 (APIO22_mars) C++17
54 / 100
502 ms 3664 KB
#include "mars.h"
#include <bits/stdc++.h>
using namespace std;
array<int, 4> get(int N, int K, int i, int j) {
    int M = N - 2 * K;
    int x = N / M;
    int y = N % M;
    if (i < y && j < y) {
        return {i * (x + 1), j * (x + 1), x + 1, x + 1};
    } else if (i < y) {
        return {i * (x + 1), y * (x + 1) + (j - y) * x, x + 1, x};
    } else if (j < y) {
        return {y * (x + 1) + (i - y) * x, j * (x + 1), x, x + 1};
    } else {
        return {y * (x + 1) + (i - y) * x, y * (x + 1) + (j - y) * x, x, x};
    }
}
constexpr int dx[] = {0, 0, -1, 1};
constexpr int dy[] = {-1, 1, 0, 0};
int cnt(vector<vector<char>> &g) {
    int n = g.size(), ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (g[i][j] == '0') {
                continue;
            }
            ans++;
            queue<pair<int, int>> q;
            g[i][j] = '0';
            q.emplace(i, j);
            while (!q.empty()) {
                auto [x, y] = q.front();
                q.pop();
                for (int i = 0; i < 4; i++) {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (min(nx, ny) >= 0 && max(nx, ny) < n && g[nx][ny] == '1') {
                        g[nx][ny] = '0';
                        q.emplace(nx, ny);
                    }
                }
            }
        }
    }
    return ans;
}
string process(vector<vector<string>> a, int X, int Y, int K, int N) {
    vector g(2 * N + 1, vector<char>(2 * N + 1));
    for (int i = X; i < X + 3; i++) {
        for (int j = Y; j < Y + 3; j++) {
            auto [s, t, u, v] = get(2 * N + 1, K, i, j);
            for (int x = s; x < s + u; x++) {
                for (int y = t; y < t + v; y++) {
                    assert(x <= 2 * N && y <= 2 * N);
                    g[x][y] = a[i - X][j - Y][v * (x - s) + (y - t)];
                }
            }
        }
    }
    string ans(100, '0');
    if (K == N - 1) {
        int land = cnt(g);
        for (int i = 0; i < 30; i++) {
            if (land >> i & 1) {
                ans[i] = '1';
            }
        }
    } else {
        auto [s, t, u, v] = get(2 * N + 1, K + 1, X, Y);
        for (int i = s; i < s + u; i++) {
            for (int j = t; j < t + v; j++) {
                assert(i <= 2 * N && j <= 2 * N);
                ans[v * (i - s) + (j - t)] = g[i][j];
            }
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
21 Correct 62 ms 2624 KB Output is correct
22 Correct 89 ms 2816 KB Output is correct
23 Correct 88 ms 2664 KB Output is correct
24 Correct 86 ms 2744 KB Output is correct
25 Correct 90 ms 2688 KB Output is correct
26 Correct 89 ms 2652 KB Output is correct
27 Correct 89 ms 2612 KB Output is correct
28 Correct 88 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
21 Correct 62 ms 2624 KB Output is correct
22 Correct 89 ms 2816 KB Output is correct
23 Correct 88 ms 2664 KB Output is correct
24 Correct 86 ms 2744 KB Output is correct
25 Correct 90 ms 2688 KB Output is correct
26 Correct 89 ms 2652 KB Output is correct
27 Correct 89 ms 2612 KB Output is correct
28 Correct 88 ms 2636 KB Output is correct
29 Correct 132 ms 2732 KB Output is correct
30 Correct 174 ms 2820 KB Output is correct
31 Correct 164 ms 2792 KB Output is correct
32 Correct 166 ms 2832 KB Output is correct
33 Correct 173 ms 2888 KB Output is correct
34 Correct 175 ms 2816 KB Output is correct
35 Correct 169 ms 2804 KB Output is correct
36 Correct 184 ms 2932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
21 Correct 62 ms 2624 KB Output is correct
22 Correct 89 ms 2816 KB Output is correct
23 Correct 88 ms 2664 KB Output is correct
24 Correct 86 ms 2744 KB Output is correct
25 Correct 90 ms 2688 KB Output is correct
26 Correct 89 ms 2652 KB Output is correct
27 Correct 89 ms 2612 KB Output is correct
28 Correct 88 ms 2636 KB Output is correct
29 Correct 132 ms 2732 KB Output is correct
30 Correct 174 ms 2820 KB Output is correct
31 Correct 164 ms 2792 KB Output is correct
32 Correct 166 ms 2832 KB Output is correct
33 Correct 173 ms 2888 KB Output is correct
34 Correct 175 ms 2816 KB Output is correct
35 Correct 169 ms 2804 KB Output is correct
36 Correct 184 ms 2932 KB Output is correct
37 Correct 239 ms 3128 KB Output is correct
38 Correct 297 ms 3288 KB Output is correct
39 Correct 296 ms 3172 KB Output is correct
40 Correct 303 ms 3220 KB Output is correct
41 Correct 293 ms 3160 KB Output is correct
42 Correct 300 ms 3160 KB Output is correct
43 Correct 298 ms 3268 KB Output is correct
44 Correct 313 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
21 Correct 62 ms 2624 KB Output is correct
22 Correct 89 ms 2816 KB Output is correct
23 Correct 88 ms 2664 KB Output is correct
24 Correct 86 ms 2744 KB Output is correct
25 Correct 90 ms 2688 KB Output is correct
26 Correct 89 ms 2652 KB Output is correct
27 Correct 89 ms 2612 KB Output is correct
28 Correct 88 ms 2636 KB Output is correct
29 Correct 132 ms 2732 KB Output is correct
30 Correct 174 ms 2820 KB Output is correct
31 Correct 164 ms 2792 KB Output is correct
32 Correct 166 ms 2832 KB Output is correct
33 Correct 173 ms 2888 KB Output is correct
34 Correct 175 ms 2816 KB Output is correct
35 Correct 169 ms 2804 KB Output is correct
36 Correct 184 ms 2932 KB Output is correct
37 Correct 239 ms 3128 KB Output is correct
38 Correct 297 ms 3288 KB Output is correct
39 Correct 296 ms 3172 KB Output is correct
40 Correct 303 ms 3220 KB Output is correct
41 Correct 293 ms 3160 KB Output is correct
42 Correct 300 ms 3160 KB Output is correct
43 Correct 298 ms 3268 KB Output is correct
44 Correct 313 ms 3436 KB Output is correct
45 Correct 379 ms 3268 KB Output is correct
46 Correct 477 ms 3396 KB Output is correct
47 Correct 460 ms 3460 KB Output is correct
48 Correct 470 ms 3480 KB Output is correct
49 Correct 467 ms 3340 KB Output is correct
50 Correct 493 ms 3428 KB Output is correct
51 Correct 480 ms 3512 KB Output is correct
52 Correct 468 ms 3632 KB Output is correct
53 Correct 476 ms 3512 KB Output is correct
54 Correct 502 ms 3600 KB Output is correct
55 Correct 494 ms 3664 KB Output is correct
56 Correct 500 ms 3352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
21 Correct 62 ms 2624 KB Output is correct
22 Correct 89 ms 2816 KB Output is correct
23 Correct 88 ms 2664 KB Output is correct
24 Correct 86 ms 2744 KB Output is correct
25 Correct 90 ms 2688 KB Output is correct
26 Correct 89 ms 2652 KB Output is correct
27 Correct 89 ms 2612 KB Output is correct
28 Correct 88 ms 2636 KB Output is correct
29 Correct 132 ms 2732 KB Output is correct
30 Correct 174 ms 2820 KB Output is correct
31 Correct 164 ms 2792 KB Output is correct
32 Correct 166 ms 2832 KB Output is correct
33 Correct 173 ms 2888 KB Output is correct
34 Correct 175 ms 2816 KB Output is correct
35 Correct 169 ms 2804 KB Output is correct
36 Correct 184 ms 2932 KB Output is correct
37 Correct 239 ms 3128 KB Output is correct
38 Correct 297 ms 3288 KB Output is correct
39 Correct 296 ms 3172 KB Output is correct
40 Correct 303 ms 3220 KB Output is correct
41 Correct 293 ms 3160 KB Output is correct
42 Correct 300 ms 3160 KB Output is correct
43 Correct 298 ms 3268 KB Output is correct
44 Correct 313 ms 3436 KB Output is correct
45 Correct 379 ms 3268 KB Output is correct
46 Correct 477 ms 3396 KB Output is correct
47 Correct 460 ms 3460 KB Output is correct
48 Correct 470 ms 3480 KB Output is correct
49 Correct 467 ms 3340 KB Output is correct
50 Correct 493 ms 3428 KB Output is correct
51 Correct 480 ms 3512 KB Output is correct
52 Correct 468 ms 3632 KB Output is correct
53 Correct 476 ms 3512 KB Output is correct
54 Correct 502 ms 3600 KB Output is correct
55 Correct 494 ms 3664 KB Output is correct
56 Correct 500 ms 3352 KB Output is correct
57 Runtime error 77 ms 716 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
21 Correct 62 ms 2624 KB Output is correct
22 Correct 89 ms 2816 KB Output is correct
23 Correct 88 ms 2664 KB Output is correct
24 Correct 86 ms 2744 KB Output is correct
25 Correct 90 ms 2688 KB Output is correct
26 Correct 89 ms 2652 KB Output is correct
27 Correct 89 ms 2612 KB Output is correct
28 Correct 88 ms 2636 KB Output is correct
29 Correct 132 ms 2732 KB Output is correct
30 Correct 174 ms 2820 KB Output is correct
31 Correct 164 ms 2792 KB Output is correct
32 Correct 166 ms 2832 KB Output is correct
33 Correct 173 ms 2888 KB Output is correct
34 Correct 175 ms 2816 KB Output is correct
35 Correct 169 ms 2804 KB Output is correct
36 Correct 184 ms 2932 KB Output is correct
37 Correct 239 ms 3128 KB Output is correct
38 Correct 297 ms 3288 KB Output is correct
39 Correct 296 ms 3172 KB Output is correct
40 Correct 303 ms 3220 KB Output is correct
41 Correct 293 ms 3160 KB Output is correct
42 Correct 300 ms 3160 KB Output is correct
43 Correct 298 ms 3268 KB Output is correct
44 Correct 313 ms 3436 KB Output is correct
45 Correct 379 ms 3268 KB Output is correct
46 Correct 477 ms 3396 KB Output is correct
47 Correct 460 ms 3460 KB Output is correct
48 Correct 470 ms 3480 KB Output is correct
49 Correct 467 ms 3340 KB Output is correct
50 Correct 493 ms 3428 KB Output is correct
51 Correct 480 ms 3512 KB Output is correct
52 Correct 468 ms 3632 KB Output is correct
53 Correct 476 ms 3512 KB Output is correct
54 Correct 502 ms 3600 KB Output is correct
55 Correct 494 ms 3664 KB Output is correct
56 Correct 500 ms 3352 KB Output is correct
57 Runtime error 77 ms 716 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1860 KB Output is correct
2 Correct 8 ms 2224 KB Output is correct
3 Correct 8 ms 2124 KB Output is correct
4 Correct 8 ms 2156 KB Output is correct
5 Correct 8 ms 2216 KB Output is correct
6 Correct 8 ms 1948 KB Output is correct
7 Correct 10 ms 1832 KB Output is correct
8 Correct 16 ms 1764 KB Output is correct
9 Correct 16 ms 2044 KB Output is correct
10 Correct 16 ms 2020 KB Output is correct
11 Correct 16 ms 2120 KB Output is correct
12 Correct 16 ms 1916 KB Output is correct
13 Correct 16 ms 2004 KB Output is correct
14 Correct 27 ms 2360 KB Output is correct
15 Correct 40 ms 2548 KB Output is correct
16 Correct 43 ms 2472 KB Output is correct
17 Correct 40 ms 2636 KB Output is correct
18 Correct 40 ms 2564 KB Output is correct
19 Correct 39 ms 2504 KB Output is correct
20 Correct 39 ms 2572 KB Output is correct
21 Correct 62 ms 2624 KB Output is correct
22 Correct 89 ms 2816 KB Output is correct
23 Correct 88 ms 2664 KB Output is correct
24 Correct 86 ms 2744 KB Output is correct
25 Correct 90 ms 2688 KB Output is correct
26 Correct 89 ms 2652 KB Output is correct
27 Correct 89 ms 2612 KB Output is correct
28 Correct 88 ms 2636 KB Output is correct
29 Correct 132 ms 2732 KB Output is correct
30 Correct 174 ms 2820 KB Output is correct
31 Correct 164 ms 2792 KB Output is correct
32 Correct 166 ms 2832 KB Output is correct
33 Correct 173 ms 2888 KB Output is correct
34 Correct 175 ms 2816 KB Output is correct
35 Correct 169 ms 2804 KB Output is correct
36 Correct 184 ms 2932 KB Output is correct
37 Correct 239 ms 3128 KB Output is correct
38 Correct 297 ms 3288 KB Output is correct
39 Correct 296 ms 3172 KB Output is correct
40 Correct 303 ms 3220 KB Output is correct
41 Correct 293 ms 3160 KB Output is correct
42 Correct 300 ms 3160 KB Output is correct
43 Correct 298 ms 3268 KB Output is correct
44 Correct 313 ms 3436 KB Output is correct
45 Correct 379 ms 3268 KB Output is correct
46 Correct 477 ms 3396 KB Output is correct
47 Correct 460 ms 3460 KB Output is correct
48 Correct 470 ms 3480 KB Output is correct
49 Correct 467 ms 3340 KB Output is correct
50 Correct 493 ms 3428 KB Output is correct
51 Correct 480 ms 3512 KB Output is correct
52 Correct 468 ms 3632 KB Output is correct
53 Correct 476 ms 3512 KB Output is correct
54 Correct 502 ms 3600 KB Output is correct
55 Correct 494 ms 3664 KB Output is correct
56 Correct 500 ms 3352 KB Output is correct
57 Runtime error 77 ms 716 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -