Submission #756350

# Submission time Handle Problem Language Result Execution time Memory
756350 2023-06-11T14:47:31 Z drdilyor Mechanical Doll (IOI18_doll) C++17
6 / 100
103 ms 11296 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 {
            while (__builtin_popcount(nxt[i].size()) > 1)
                nxt[i].push_back(INT_MAX);
            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);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 30 ms 6352 KB Output is correct
3 Correct 24 ms 5072 KB Output is correct
4 Correct 1 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 30 ms 6352 KB Output is correct
3 Correct 24 ms 5072 KB Output is correct
4 Correct 1 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 0 ms 212 KB Output is correct
8 Correct 53 ms 7240 KB Output is correct
9 Correct 59 ms 8504 KB Output is correct
10 Correct 94 ms 11296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 30 ms 6352 KB Output is correct
3 Correct 24 ms 5072 KB Output is correct
4 Correct 1 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 0 ms 212 KB Output is correct
8 Correct 53 ms 7240 KB Output is correct
9 Correct 59 ms 8504 KB Output is correct
10 Correct 94 ms 11296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 103 ms 10892 KB state 'Y'
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB state 'Y'
2 Halted 0 ms 0 KB -