답안 #405012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405012 2021-05-15T14:40:40 Z two_sides 자동 인형 (IOI18_doll) C++17
100 / 100
143 ms 7936 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

int construct(const vector <int> &A,
int &S, vector <int> &X, vector <int> &Y) {
    int N = A.size();
    if (N == 0) return 0;
    else if (N == 1) return A[0];
    int k = 0;
    while ((1 << k) < N) k++;
    int M = 1 << k;
    vector <int> rev(M), mat(M);
    for (int i = 0; i < M; i++)
        rev[i] = (rev[i >> 1] >> 1)
        | ((i & 1) << (k - 1));
    int root = --S;
    for (int l = 0; l + 1 < k; l++)
        for (int i = 0; i < (1 << l); i++)
            if ((i << (k - l)) +
            (1 << (k - l)) > (M - N)) {
                if ((i << (k - l)) +
                (1 << (k - l - 1)) <= M - N) {
                    X.push_back(root);
                    Y.push_back(--S);
                } else {
                    X.push_back(--S);
                    Y.push_back(--S);
                }
            }
    for (int i = 0, j = 0; i < M; i++)
        if (rev[i] >= (M - N))
            mat[rev[i]] = A[j++];
    for (int i = 0; i < (M >> 1); i++)
        if ((i << 1) + 2 > M - N) {
            if ((i << 1) + 1 <= M - N) {
                X.push_back(root);
                Y.push_back(mat[(i << 1) + 1]);
            } else {
                X.push_back(mat[i << 1]);
                Y.push_back(mat[(i << 1) + 1]);
            }
        }
    return root;
}
void create_circuit(int M, vector <int> A) {
    int S = 0; vector <int> X, Y;
    A.push_back(0);
    int root = construct(A, S, X, Y);
    answer(vector <int> (M + 1, root), X, Y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 42 ms 3884 KB Output is correct
3 Correct 36 ms 3520 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 13 ms 996 KB Output is correct
6 Correct 51 ms 5008 KB Output is correct
7 Correct 2 ms 216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 42 ms 3884 KB Output is correct
3 Correct 36 ms 3520 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 13 ms 996 KB Output is correct
6 Correct 51 ms 5008 KB Output is correct
7 Correct 2 ms 216 KB Output is correct
8 Correct 55 ms 5704 KB Output is correct
9 Correct 90 ms 5668 KB Output is correct
10 Correct 83 ms 7936 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 42 ms 3884 KB Output is correct
3 Correct 36 ms 3520 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 13 ms 996 KB Output is correct
6 Correct 51 ms 5008 KB Output is correct
7 Correct 2 ms 216 KB Output is correct
8 Correct 55 ms 5704 KB Output is correct
9 Correct 90 ms 5668 KB Output is correct
10 Correct 83 ms 7936 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 143 ms 7636 KB Output is correct
15 Correct 51 ms 5704 KB Output is correct
16 Correct 77 ms 7388 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 2 ms 204 KB Output is correct
20 Correct 81 ms 7652 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 51 ms 5676 KB Output is correct
3 Correct 52 ms 5796 KB Output is correct
4 Correct 77 ms 6824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 51 ms 5676 KB Output is correct
3 Correct 52 ms 5796 KB Output is correct
4 Correct 77 ms 6824 KB Output is correct
5 Correct 75 ms 7180 KB Output is correct
6 Correct 112 ms 7032 KB Output is correct
7 Correct 94 ms 7008 KB Output is correct
8 Correct 71 ms 6824 KB Output is correct
9 Correct 46 ms 5696 KB Output is correct
10 Correct 87 ms 6828 KB Output is correct
11 Correct 73 ms 6808 KB Output is correct
12 Correct 53 ms 5704 KB Output is correct
13 Correct 52 ms 5696 KB Output is correct
14 Correct 50 ms 5680 KB Output is correct
15 Correct 62 ms 5676 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 68 ms 5664 KB Output is correct
18 Correct 46 ms 5704 KB Output is correct
19 Correct 46 ms 5708 KB Output is correct
20 Correct 80 ms 6836 KB Output is correct
21 Correct 73 ms 6824 KB Output is correct
22 Correct 79 ms 6832 KB Output is correct