답안 #756351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756351 2023-06-11T14:48:56 Z drdilyor 자동 인형 (IOI18_doll) C++17
53 / 100
163 ms 14384 KB
#include<bits/stdc++.h>
#include "doll.h"
using namespace std;
using ll = long long;

void create_circuit(int m, std::vector<int> arr) {
    vector<int> c(m+1);
    vector<int> x, y;
    auto add = [&](int a, int b){
        x.push_back(a), y.push_back(b);
        return -(int)x.size();
    };

    auto tree = [&](auto& tree, vector<int> nxt) {
        if (nxt.size() == 1) {
            return nxt[0];
        }
        vector<int> odd, even;
        for (int i = 0; i < (int)nxt.size(); i += 2) {
            odd.push_back(nxt[i]);
            even.push_back(nxt[i+1]);
        }
        int t1 = tree(tree, odd);
        int t2 = tree(tree, even);
        return add(t1, t2);
    };

    int n = arr.size();
    vector<vector<int>> nxt(m+1);
    arr.push_back(0);
    for (int i = 0; i < n; i++) {
        nxt[arr[i]].push_back(arr[i+1]);
    }
    for (int i = 1; i <= m; i++) {
        if (nxt[i].empty()) {
            c[i] = 0;
        } else {
            reverse(nxt[i].begin(), nxt[i].end());
            while (__builtin_popcount(nxt[i].size()) > 1)
                nxt[i].push_back(INT_MAX);
            reverse(nxt[i].begin(), nxt[i].end());

            int start = x.size();
            c[i] = tree(tree, nxt[i]);
            while (start < (int)x.size()) {
                if (x[start] == INT_MAX)
                    x[start] = c[i];
                if (y[start] == INT_MAX)
                    y[start] = c[i];
                start++;
            }
        }
    }
    c[0] = arr[0];
    answer(c, x, y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 29 ms 6352 KB Output is correct
3 Correct 23 ms 5072 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 10 ms 3796 KB Output is correct
6 Correct 38 ms 7628 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 29 ms 6352 KB Output is correct
3 Correct 23 ms 5072 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 10 ms 3796 KB Output is correct
6 Correct 38 ms 7628 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 60 ms 7196 KB Output is correct
9 Correct 57 ms 8520 KB Output is correct
10 Correct 97 ms 11244 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 29 ms 6352 KB Output is correct
3 Correct 23 ms 5072 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 10 ms 3796 KB Output is correct
6 Correct 38 ms 7628 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 60 ms 7196 KB Output is correct
9 Correct 57 ms 8520 KB Output is correct
10 Correct 97 ms 11244 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 114 ms 10976 KB Output is correct
15 Correct 51 ms 6048 KB Output is correct
16 Correct 83 ms 8688 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 104 ms 10608 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 63 ms 6856 KB Output is correct
3 Partially correct 128 ms 11392 KB Output is partially correct
4 Partially correct 125 ms 12116 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 63 ms 6856 KB Output is correct
3 Partially correct 128 ms 11392 KB Output is partially correct
4 Partially correct 125 ms 12116 KB Output is partially correct
5 Partially correct 130 ms 13148 KB Output is partially correct
6 Partially correct 143 ms 13624 KB Output is partially correct
7 Partially correct 138 ms 13584 KB Output is partially correct
8 Partially correct 151 ms 13828 KB Output is partially correct
9 Partially correct 116 ms 10596 KB Output is partially correct
10 Partially correct 163 ms 14384 KB Output is partially correct
11 Partially correct 163 ms 14256 KB Output is partially correct
12 Partially correct 104 ms 9712 KB Output is partially correct
13 Partially correct 97 ms 9140 KB Output is partially correct
14 Partially correct 89 ms 9092 KB Output is partially correct
15 Partially correct 86 ms 8924 KB Output is partially correct
16 Partially correct 3 ms 596 KB Output is partially correct
17 Partially correct 85 ms 7996 KB Output is partially correct
18 Partially correct 84 ms 8084 KB Output is partially correct
19 Partially correct 96 ms 8428 KB Output is partially correct
20 Partially correct 118 ms 10912 KB Output is partially correct
21 Partially correct 148 ms 12880 KB Output is partially correct
22 Partially correct 111 ms 10420 KB Output is partially correct