답안 #1014953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014953 2024-07-05T19:16:13 Z ThegeekKnight16 자동 인형 (IOI18_doll) C++17
70.6719 / 100
87 ms 9404 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;

int build(int qnt, int &extra, vector<int> &X, vector<int> &Y)
{
    if (qnt == 1) return 0;
    X.push_back(-1); Y.push_back(-1);
    int id = X.size();
    if (qnt <= extra)
    {
        extra -= qnt;
        return -id;
    }

    int e = build(qnt/2, extra, X, Y), d = build(qnt/2, extra, X, Y);
    X[id-1] = e, Y[id-1] = d;
    return -id;
}

void create_circuit(int M, std::vector<int> A)
{
    int N = A.size();
    if (N == 1)
    {
        vector<int> C = {A[0], 0};
        vector<int> X, Y;
        answer(C, X, Y);
        return;
    }
    vector<int> X, Y;
    int qnt = 1;
    while (qnt < N) qnt *= 2;
    int extra = qnt - N;
    bool delay = 0;
    if (extra % 2) extra--, delay = 1;
    build(qnt, extra, X, Y);

    vector<int> C(M+1, -1); C[0] = (delay ? -1 : A[0]);
    vector<int> state(X.size());
    for (int i = 1-(int)delay; i < N; i++)
    {
        int id = -1;
        while (id < 0)
        {
            int nextId = (state[-id-1] ? Y[-id-1] : X[-id-1]);
            state[-id-1] ^= 1;
            if (nextId == 0)
            {
                if (state[-id-1]) X[-id-1] = A[i];
                else Y[-id-1] = A[i];
                break;
            }
            id = nextId;
        }
    }
    answer(C, X, Y);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Correct 49 ms 6116 KB Output is correct
3 Partially correct 51 ms 6160 KB Output is partially correct
4 Correct 87 ms 9128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Correct 49 ms 6116 KB Output is correct
3 Partially correct 51 ms 6160 KB Output is partially correct
4 Correct 87 ms 9128 KB Output is correct
5 Correct 76 ms 9404 KB Output is correct
6 Correct 86 ms 9152 KB Output is correct
7 Correct 77 ms 9104 KB Output is correct
8 Correct 77 ms 9100 KB Output is correct
9 Partially correct 43 ms 5832 KB Output is partially correct
10 Correct 79 ms 9124 KB Output is correct
11 Partially correct 74 ms 9152 KB Output is partially correct
12 Partially correct 46 ms 5764 KB Output is partially correct
13 Correct 49 ms 6208 KB Output is correct
14 Partially correct 53 ms 6324 KB Output is partially correct
15 Partially correct 48 ms 6268 KB Output is partially correct
16 Partially correct 2 ms 604 KB Output is partially correct
17 Correct 48 ms 6192 KB Output is correct
18 Correct 52 ms 6216 KB Output is correct
19 Partially correct 46 ms 5828 KB Output is partially correct
20 Correct 72 ms 9104 KB Output is correct
21 Correct 74 ms 9152 KB Output is correct
22 Correct 70 ms 9148 KB Output is correct