Submission #240933

#TimeUsernameProblemLanguageResultExecution timeMemory
240933Ruxandra985Mechanical Doll (IOI18_doll)C++14
37 / 100
163 ms26020 KiB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;

void create_circuit(int m, vector<int> a) {
    int n = a.size() , i , l , aux , conf;
    vector <int> c;
    vector <int> x , y , w[400010];

    c.push_back(-1);

    for (i = 1 ; i <= m ; i++)
        c.push_back(-1);

    /// trb sa vezi cate noduri nu iti sunt necesare

    l = 0;
    while ((1 << l) <= n){
        l++;
    }


    for (i = 1 ; i <= (1 << l) - 1 ; i++){

        if (2 * i <= (1 << l) - 1){

            w[i].push_back(2 * i);
            w[i].push_back(2 * i + 1);

        }

    }

    for (i = 1 ; i <= (1 << l) - 1 ; i++){

        if (2 * i > (1 << l) - 1){

            aux = 2 * i;
            conf = 0;

            while (aux){
                conf = conf * 2 + (aux % 2);
                aux /= 2;
            }

            conf /= 2;

            if (conf < a.size())
                w[i].push_back(-a[conf]);
            else if (conf == (1 << l) - 1){
                w[i].push_back(0);
            }
            else w[i].push_back(1);

            /// -----------------------------------

            aux = 2 * i + 1;
            conf = 0;

            while (aux){
                conf = conf * 2 + (aux % 2);
                aux /= 2;
            }

            conf /= 2;

            if (conf < a.size())
                w[i].push_back(-a[conf]);
            else if (conf == (1 << l) - 1){
                w[i].push_back(0);
            }
            else w[i].push_back(1);


        }

    }


    x.resize((1 << l) - 1 , 0);
    y.resize((1 << l) - 1 , 0);



    for (i = 1 ; i <= (1 << l) - 1 ; i++){

        x[i - 1] = -w[i][0];
        y[i - 1] = -w[i][1];

    }

    answer (c , x , y);

}

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             if (conf < a.size())
      |                 ~~~~~^~~~~~~~~~
doll.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if (conf < a.size())
      |                 ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...