Submission #823599

# Submission time Handle Problem Language Result Execution time Memory
823599 2023-08-12T20:13:05 Z someone Mechanical Doll (IOI18_doll) C++14
84 / 100
103 ms 9888 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9 + 42;

int id = 0, n;
vector<int> nxt[2], state;

int tree(int lvl, int deb) {
    if(deb >= n) return -INF;
    if(lvl == 0) return 0;
    lvl--;
    int mid = deb + (1 << (lvl));
    int right = tree(lvl, deb), left = tree(lvl, mid);
    nxt[0].push_back(left);
    nxt[1].push_back(right);
    return --id;
}

void create_circuit(int M, vector<int> A) {
    A.push_back(0);
    n = (int)A.size();
    vector<int> C(M + 1);
    int len = 0;
    while((1 << len) <= n) len++;
    tree(len, 0);
    int sz = (int)nxt[0].size();
    for (int i = 0; i <= M; ++i)
        C[i] = -sz;
    for(int i = 0; i < sz; i++) {
        if(nxt[0][i] == -INF)
            nxt[0][i] = -sz;
        if(nxt[1][i] == -INF)
            nxt[1][i] = -sz;
    }
    state.resize((int)nxt[0].size());
    id = 0;
    int i = sz-1;
    while(i != -1) {
        int nex = -nxt[state[i]][i]-1;
        if(nxt[state[i]][i] == 0) {
            nxt[state[i]][i] = A[id++];
            nex = sz-1;
            if(nxt[state[i]][i] == 0) nex = -1;
        }
        state[i] = 1 - state[i];
        i = nex;
    }
    answer(C, nxt[0], nxt[1]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 43 ms 4908 KB Output is correct
3 Correct 34 ms 5068 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 ms 1492 KB Output is correct
6 Correct 53 ms 7248 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 43 ms 4908 KB Output is correct
3 Correct 34 ms 5068 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 ms 1492 KB Output is correct
6 Correct 53 ms 7248 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 43 ms 4908 KB Output is correct
3 Correct 34 ms 5068 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 ms 1492 KB Output is correct
6 Correct 53 ms 7248 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 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 60 ms 5560 KB Output is correct
3 Correct 60 ms 5596 KB Output is correct
4 Correct 93 ms 8464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 60 ms 5560 KB Output is correct
3 Correct 60 ms 5596 KB Output is correct
4 Correct 93 ms 8464 KB Output is correct
5 Correct 97 ms 9888 KB Output is correct
6 Correct 95 ms 9500 KB Output is correct
7 Correct 97 ms 9624 KB Output is correct
8 Correct 97 ms 9260 KB Output is correct
9 Correct 61 ms 5500 KB Output is correct
10 Correct 96 ms 9184 KB Output is correct
11 Correct 94 ms 8756 KB Output is correct
12 Correct 62 ms 5800 KB Output is correct
13 Correct 63 ms 6252 KB Output is correct
14 Correct 67 ms 6436 KB Output is correct
15 Correct 70 ms 6540 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 58 ms 6168 KB Output is correct
18 Correct 63 ms 5820 KB Output is correct
19 Correct 62 ms 5736 KB Output is correct
20 Correct 103 ms 9024 KB Output is correct
21 Correct 95 ms 8748 KB Output is correct
22 Correct 95 ms 8764 KB Output is correct