Submission #75291

# Submission time Handle Problem Language Result Execution time Memory
75291 2018-09-09T06:32:08 Z KieranHorgan Mechanical Doll (IOI18_doll) C++17
0 / 100
1 ms 224 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> A, X, Y, C;
int nextTrigger = -1;
int solve(vector<int> a) {
  int trigger = nextTrigger--;
  if(a.size() == 1) return a[0];
  vector<int> b;
  for(int i = 0; i < a.size(); i+=2)
    b.push_back(a[i]);
  int l = solve(b);
  b.clear();
  for(int i = 1; i < a.size(); i+=2)
    b.push_back(a[i]);
  int r = solve(b);
  b.clear();

  if(X.size() < -(trigger+1))
    X.resize(-(trigger)), Y.resize(-(trigger));
  X[-(trigger+1)] = l;
  Y[-(trigger+1)] = r;
  return trigger;
}

void create_circuit(int M, vector<int> A_) {
  A = A_;
  int N = A.size();
  while(__builtin_popcount(A.size()+1) != 1) {
    A.push_back(-1);
  }
  A.push_back(0);
  C.assign(M+1, -1);

  solve(A);

  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'int solve(std::vector<int>)':
doll.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   for(int i = 0; i < a.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i = 1; i < a.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:20:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |   if(X.size() < -(trigger+1))
      |      ~~~~~~~~~^~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:29:7: warning: unused variable 'N' [-Wunused-variable]
   29 |   int 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 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 224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 224 KB Output isn't correct
2 Halted 0 ms 0 KB -