Submission #75975

# Submission time Handle Problem Language Result Execution time Memory
75975 2018-09-11T18:03:27 Z dimatc Mechanical Doll (IOI18_doll) C++14
37 / 100
103 ms 10280 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

int sw, k, H, leaves;
vector<int> X(400015), Y(400015);

void add(vector<int> &V2, vector<int> &V1, vector<int> &A) {
    for (auto x : V1) {
        if (k == H) {
            if (leaves > A.size() - 1) X[x-1] = -1, leaves++;
            else X[x-1] = A[leaves++];
        } else {
            ++sw;
            X[x-1] = -sw;
            V2.push_back(sw);
        }
    }
    for (auto x: V1) {
        if (k == H) {
            if (leaves > A.size() - 1) Y[x-1] = -1, leaves++;
            else Y[x-1] = A[leaves++];
        } else {
            ++sw;
            Y[x-1] = -sw;
            V2.push_back(sw);
        }
    }
    V1.clear();
}

void create_circuit(int M, std::vector<int> A) {
    vector<int> C(M + 1), V1, V2;
    int N = A.size()+1;
    for (H=0; (1<<H) < N; H++);

    k = 1; sw=1;
    V1.push_back(sw);
    while (k <= H) {
        if (!V1.size()) add(V1, V2, A);
        else add(V2, V1, A);
        ++k;
    }
    Y[sw-1]=0;
    for (int i=0; i<M+1; i++) C[i]=-1;

    X.resize(leaves-1);
    Y.resize(leaves-1);
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void add(std::vector<int>&, std::vector<int>&, std::vector<int>&)':
doll.cpp:11:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |             if (leaves > A.size() - 1) X[x-1] = -1, leaves++;
      |                 ~~~~~~~^~~~~~~~~~~~~~
doll.cpp:21:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if (leaves > A.size() - 1) Y[x-1] = -1, leaves++;
      |                 ~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 3404 KB Output is partially correct
2 Partially correct 82 ms 9408 KB Output is partially correct
3 Partially correct 103 ms 9456 KB Output is partially correct
4 Partially correct 79 ms 9968 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 3404 KB Output is partially correct
2 Partially correct 82 ms 9408 KB Output is partially correct
3 Partially correct 103 ms 9456 KB Output is partially correct
4 Partially correct 79 ms 9968 KB Output is partially correct
5 Partially correct 87 ms 10280 KB Output is partially correct
6 Partially correct 85 ms 10032 KB Output is partially correct
7 Partially correct 92 ms 10112 KB Output is partially correct
8 Partially correct 81 ms 10032 KB Output is partially correct
9 Partially correct 78 ms 9440 KB Output is partially correct
10 Partially correct 82 ms 9984 KB Output is partially correct
11 Partially correct 89 ms 9920 KB Output is partially correct
12 Partially correct 75 ms 9452 KB Output is partially correct
13 Partially correct 77 ms 9492 KB Output is partially correct
14 Partially correct 80 ms 9512 KB Output is partially correct
15 Partially correct 82 ms 9604 KB Output is partially correct
16 Partially correct 5 ms 3660 KB Output is partially correct
17 Correct 49 ms 7144 KB Output is correct
18 Partially correct 78 ms 9444 KB Output is partially correct
19 Partially correct 72 ms 9376 KB Output is partially correct
20 Partially correct 83 ms 9896 KB Output is partially correct
21 Partially correct 81 ms 10028 KB Output is partially correct
22 Partially correct 91 ms 9964 KB Output is partially correct