답안 #891655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891655 2023-12-23T13:43:47 Z vjudge1 자동 인형 (IOI18_doll) C++17
84 / 100
89 ms 11316 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

vi X, Y;

vector<pair<int, int> > VP;

int gen(int niv, int nr) {
    int id = X.size();
    X.push_back(0);
    Y.push_back(0);
    //cout << niv << " " << nr << "\n";
    if(niv == 1 && nr == 2) {
        return -id - 1; 
    } else if(niv == 1 && nr == 1) {
        X[id] = -1;
        return -id - 1;
    }
    
    if(nr <= (1 << (niv - 1))) {
        int S = gen(niv - 1, nr);
        Y[id] = S;
        X[id] = -1;
        return -id - 1;
    } else {
        Y[id] = gen(niv - 1, (1 << (niv - 1)));
        X[id] = gen(niv - 1, nr - (1 << (niv - 1)));
        return -id - 1;
    }
    return -id - 1;

}

void create_circuit(int M, vi A) {
    A.push_back(0);
    int niv = 1;
    while((1 << niv) <= A.size()) ++niv;
    gen(niv, A.size());
    vi C(M + 1, -1);

    vi Stare(X.size(), 0);

    int u = -1, p = 0;
    ////cout << "ASSIGN\n";
    do {
        if(u > 0) {
            u = -1;
        }
        int id = -u - 1;
        if(!Stare[id]) {
            Stare[id] ^= 1;
            if(X[id]) u = X[id];
            else {
                u = X[id] = A[p++];
            }
        } else {
            Stare[id] ^= 1;
            if(Y[id]) u = Y[id];
            else {
                u = Y[id] = A[p++];
            }
        }
    } while(u != 0);

    int nr0 = 0;
    for(auto &it : X) nr0 += !it;
    for(auto &it : Y) nr0 += !it;

    //cout << "In total " << nr0 << "\n";


    //for(auto it : Stare)
        //cout << it << " ";
    //cout << "\n";

    //cout << "C: ";
    //for(auto it : C) 
        //cout << it << " ";
    //cout << "\n";
    //cout << "X: ";
    //for(auto it : X) 
        //cout << it << " ";
    //cout << "\n";
    //cout << "Y: ";
    //for(auto it : Y) 
        //cout << it << " ";
    //cout << "\n";
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, vi)':
doll.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     while((1 << niv) <= A.size()) ++niv;
      |           ~~~~~~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 30 ms 5068 KB Output is correct
3 Correct 29 ms 4936 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 7 ms 1624 KB Output is correct
6 Correct 43 ms 7056 KB Output is correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 30 ms 5068 KB Output is correct
3 Correct 29 ms 4936 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 7 ms 1624 KB Output is correct
6 Correct 43 ms 7056 KB Output is correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 30 ms 5068 KB Output is correct
3 Correct 29 ms 4936 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 7 ms 1624 KB Output is correct
6 Correct 43 ms 7056 KB Output is correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 Correct 1 ms 348 KB Output is correct
2 Correct 53 ms 6476 KB Output is correct
3 Correct 52 ms 6580 KB Output is correct
4 Correct 79 ms 10036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 53 ms 6476 KB Output is correct
3 Correct 52 ms 6580 KB Output is correct
4 Correct 79 ms 10036 KB Output is correct
5 Correct 84 ms 11316 KB Output is correct
6 Correct 83 ms 11056 KB Output is correct
7 Correct 82 ms 11060 KB Output is correct
8 Correct 80 ms 10740 KB Output is correct
9 Correct 52 ms 6512 KB Output is correct
10 Correct 83 ms 10776 KB Output is correct
11 Correct 89 ms 10292 KB Output is correct
12 Correct 52 ms 6772 KB Output is correct
13 Correct 56 ms 7288 KB Output is correct
14 Correct 55 ms 7280 KB Output is correct
15 Correct 55 ms 7496 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 49 ms 7216 KB Output is correct
18 Correct 53 ms 6768 KB Output is correct
19 Correct 53 ms 6776 KB Output is correct
20 Correct 81 ms 10544 KB Output is correct
21 Correct 81 ms 10292 KB Output is correct
22 Correct 82 ms 10292 KB Output is correct