답안 #971745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971745 2024-04-29T08:46:27 Z fve5 자동 인형 (IOI18_doll) C++17
100 / 100
108 ms 11608 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;

#define MAXS 400'000

void create_circuit(int M, vector<int> A) {
    int N = A.size();

    vector<int> C(M + 1, -1), X(MAXS), Y(MAXS);
    int cnt = 0;

    auto get_idx = [&](int sw) {
        return abs(sw) - 1;
    };

    auto rec = [&](auto &&rec, int l, int r) {
        if ((1 << (int)ceil(log2(N + 1))) - r > N) return -1;
        if (r - l == 1) return 0;

        int node_idx = --cnt;

        int lc = rec(rec, l, (l + r + 1) / 2);
        int rc = rec(rec, (l + r + 1) / 2, r);
    
        X[get_idx(node_idx)] = lc;
        Y[get_idx(node_idx)] = rc;
        return node_idx;
    };

    rec(rec, 0, 1 << (int)ceil(log2(N + 1)));
    X.resize(abs(cnt));
    Y.resize(abs(cnt));

    vector<int> status(abs(cnt));
    for (int i = 0; i <= N; i++) {
        int curr = -1;
        for (;;) {
            status[get_idx(curr)] ^= 1;
            int next = status[get_idx(curr)] ? X[get_idx(curr)] : Y[get_idx(curr)];
            
            if (next == 0) {
                int sus = i == N ? 0 : A[i];
                if (status[get_idx(curr)]) X[get_idx(curr)] = sus;
                else Y[get_idx(curr)] = sus;

                break;
            }

            curr = next;
        }
    }

    answer(C, X, Y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3676 KB Output is correct
2 Correct 37 ms 6996 KB Output is correct
3 Correct 34 ms 6492 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 9 ms 4700 KB Output is correct
6 Correct 53 ms 8020 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3676 KB Output is correct
2 Correct 37 ms 6996 KB Output is correct
3 Correct 34 ms 6492 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 9 ms 4700 KB Output is correct
6 Correct 53 ms 8020 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
8 Correct 64 ms 8872 KB Output is correct
9 Correct 75 ms 9248 KB Output is correct
10 Correct 106 ms 11608 KB Output is correct
11 Correct 2 ms 3420 KB Output is correct
12 Correct 1 ms 3508 KB Output is correct
13 Correct 2 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3676 KB Output is correct
2 Correct 37 ms 6996 KB Output is correct
3 Correct 34 ms 6492 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 9 ms 4700 KB Output is correct
6 Correct 53 ms 8020 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
8 Correct 64 ms 8872 KB Output is correct
9 Correct 75 ms 9248 KB Output is correct
10 Correct 106 ms 11608 KB Output is correct
11 Correct 2 ms 3420 KB Output is correct
12 Correct 1 ms 3508 KB Output is correct
13 Correct 2 ms 3416 KB Output is correct
14 Correct 103 ms 11096 KB Output is correct
15 Correct 64 ms 8272 KB Output is correct
16 Correct 102 ms 10896 KB Output is correct
17 Correct 1 ms 3420 KB Output is correct
18 Correct 2 ms 3420 KB Output is correct
19 Correct 2 ms 3420 KB Output is correct
20 Correct 105 ms 11272 KB Output is correct
21 Correct 2 ms 3420 KB Output is correct
22 Correct 2 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3420 KB Output is correct
2 Correct 2 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 2 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 2 ms 3420 KB Output is correct
7 Correct 2 ms 3500 KB Output is correct
8 Correct 2 ms 3420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 63 ms 8084 KB Output is correct
3 Correct 62 ms 8016 KB Output is correct
4 Correct 95 ms 10324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3416 KB Output is correct
2 Correct 63 ms 8084 KB Output is correct
3 Correct 62 ms 8016 KB Output is correct
4 Correct 95 ms 10324 KB Output is correct
5 Correct 101 ms 10748 KB Output is correct
6 Correct 101 ms 10544 KB Output is correct
7 Correct 97 ms 10804 KB Output is correct
8 Correct 98 ms 10600 KB Output is correct
9 Correct 63 ms 8092 KB Output is correct
10 Correct 108 ms 10580 KB Output is correct
11 Correct 96 ms 10460 KB Output is correct
12 Correct 61 ms 8020 KB Output is correct
13 Correct 70 ms 8276 KB Output is correct
14 Correct 67 ms 8100 KB Output is correct
15 Correct 77 ms 8272 KB Output is correct
16 Correct 3 ms 3676 KB Output is correct
17 Correct 62 ms 7980 KB Output is correct
18 Correct 63 ms 8092 KB Output is correct
19 Correct 67 ms 8096 KB Output is correct
20 Correct 94 ms 10464 KB Output is correct
21 Correct 97 ms 10464 KB Output is correct
22 Correct 94 ms 10320 KB Output is correct