Submission #284573

# Submission time Handle Problem Language Result Execution time Memory
284573 2020-08-27T16:32:49 Z MKopchev Mechanical Doll (IOI18_doll) C++14
47 / 100
186 ms 10352 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

const int nmax=1e6+42;

int n;

vector<int> X,Y;

int pointer=0;

int stop;

bool type[nmax];

void push(int node,int val)
{
    //cout<<"push "<<node<<" "<<val<<endl;

    if(node<stop)
    {
        int to=-X[node];

        if(type[node]==1)to=-Y[node];

        type[node]=!type[node];

        push(to,val);
        return;
    }
    else
    {
        if(type[node]==0)X[node]=val;
        else Y[node]=val;

        type[node]=!type[node];
        return;
    }
}
/*
void answer(vector<int> c,vector<int> x,vector<int> y)
{
    cout<<c.size()<<" "<<x.size()<<" "<<y.size()<<endl;

    cout<<"c: ";for(auto k:c)cout<<k<<" ";cout<<endl;
    cout<<"x: ";for(auto k:x)cout<<k<<" ";cout<<endl;
    cout<<"y: ";for(auto k:y)cout<<k<<" ";cout<<endl;
}
*/
vector<int> C={};

void create_circuit(int M, std::vector<int> A)
{
    int orig_n=A.size();

    n=A.size();

    for(int j=0;j<=M;j++)
        C.push_back(-1);

    C[0]=A[0];

    A.erase(A.begin(),A.begin()+1);
    n--;

    int k=1;

    while((1<<k)<n+1)k++;

    while(n+1<(1<<k))
    {
        A.push_back(-1);
        n++;
    }

    A.push_back(0);
    n++;

    //for(auto k:A)cout<<k<<" ";cout<<endl;

    stop=(1<<(k-1));

    for(int i=0;i<(1<<k);i++)
    {
        X.push_back(-1);
        Y.push_back(-1);
    }

    for(int i=1;i<(1<<(k-1));i++)
    {
        X[i]=-(2*i);
        Y[i]=-(2*i+1);
    }

    for(int i=0;i<n;i++)
    {
        push(1,A[i]);
    }

    for(int i=0;i<X.size();i++)
        assert(type[i]==0);

    X.erase(X.begin(),X.begin()+1);

    Y.erase(Y.begin(),Y.begin()+1);

    answer(C,X,Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:101:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |     for(int i=0;i<X.size();i++)
      |                 ~^~~~~~~~~
doll.cpp:55:9: warning: unused variable 'orig_n' [-Wunused-variable]
   55 |     int orig_n=A.size();
      |         ^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 91 ms 4752 KB Output is correct
3 Partially correct 123 ms 8296 KB Output is partially correct
4 Partially correct 137 ms 9380 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 91 ms 4752 KB Output is correct
3 Partially correct 123 ms 8296 KB Output is partially correct
4 Partially correct 137 ms 9380 KB Output is partially correct
5 Partially correct 149 ms 10352 KB Output is partially correct
6 Partially correct 144 ms 10220 KB Output is partially correct
7 Partially correct 169 ms 10244 KB Output is partially correct
8 Partially correct 130 ms 9440 KB Output is partially correct
9 Partially correct 128 ms 8300 KB Output is partially correct
10 Partially correct 130 ms 9996 KB Output is partially correct
11 Partially correct 167 ms 9784 KB Output is partially correct
12 Partially correct 117 ms 8300 KB Output is partially correct
13 Correct 67 ms 4852 KB Output is correct
14 Partially correct 125 ms 8576 KB Output is partially correct
15 Partially correct 130 ms 8616 KB Output is partially correct
16 Partially correct 4 ms 588 KB Output is partially correct
17 Correct 73 ms 5820 KB Output is correct
18 Correct 63 ms 4756 KB Output is correct
19 Partially correct 186 ms 8384 KB Output is partially correct
20 Partially correct 134 ms 9204 KB Output is partially correct
21 Partially correct 141 ms 9632 KB Output is partially correct
22 Partially correct 148 ms 9712 KB Output is partially correct