Submission #153793

#TimeUsernameProblemLanguageResultExecution timeMemory
153793AlexLuchianovMechanical Doll (IOI18_doll)C++14
0 / 100
1 ms204 KiB
#include "doll.h"
#include <iostream>
#include <vector>

using namespace std;

int const nmax = 200000;
int leftp[1 + nmax];
int rightp[1 + nmax];
int switches = 0;

int createpath(vector<int> dest){
  if(dest.size() == 1)
    return dest[0];

  vector<int> desteven, destodd;
  for(int i = 0; i < dest.size(); i += 2)
    destodd.push_back(dest[i]);

  for(int i = 1; i < dest.size(); i += 2)
    desteven.push_back(dest[i]);

  int central = -(++switches);

  leftp[switches] = createpath(destodd);
  rightp[switches] = createpath(desteven);
  return central;
}


void create_circuit(int M, std::vector<int> A) {

  int N = A.size();
  std::vector<int> C(M + 1);
  C[0] = 0;
  for (int i = 1; i <= M; ++i)
    C[i] = -1;

  vector<int> dest;
  for(int i = 0; i < A.size(); i++)
    dest.push_back(A[i]);
  dest.push_back(0);
  createpath(dest);

  std::vector<int> X(switches), Y(switches);

  for (int k = 1; k <= switches; ++k) {
    X[k - 1] = leftp[k];
    Y[k - 1] = rightp[k];
  }

  answer(C, X, Y);
}

Compilation message (stderr)

doll.cpp: In function 'int createpath(std::vector<int>)':
doll.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int i = 0; i < dest.size(); i += 2)
      |                  ~~^~~~~~~~~~~~~
doll.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i = 1; i < dest.size(); i += 2)
      |                  ~~^~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i = 0; i < A.size(); i++)
      |                  ~~^~~~~~~~~~
doll.cpp:33:7: warning: unused variable 'N' [-Wunused-variable]
   33 |   int N = 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...