Submission #626135

# Submission time Handle Problem Language Result Execution time Memory
626135 2022-08-11T08:59:16 Z evenvalue Mechanical Doll (IOI18_doll) C++17
18 / 100
22 ms 3540 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;

using int64 = long long;
using ld = long double;

constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;


int calc_elements(const int n) {
  const int h = 32 - __builtin_clz(n) - (__builtin_popcount(n) == 1);
  return (1 << h);
}

void create_circuit(int m, std::vector<int> A) {
  assert(m == 1);
  int n = A.size();
  vector<int> C(2);
  vector<int> X;
  vector<int> Y;

  function<void(int)> dfs = [&](const int enter) {
    X.push_back(0), Y.push_back(0);
    //set my left child
    if (enter / 2 < n) {
      X.back() = 1;
      n -= enter / 2;
    } else {
      X.back() = -1;
    }
    //set my right child
    if (n == 1 and enter == 2) {
      Y.back() = 0;
    } else {
      Y.back() = -1 * (int)(1 + Y.size());
      dfs(enter / 2);
    }
  };
  dfs(calc_elements(n));
  C[0] = 1;
  C[1] = -1;
  answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 12 ms 1336 KB Output is correct
3 Correct 12 ms 1236 KB Output is correct
4 Correct 21 ms 1848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 12 ms 1336 KB Output is correct
3 Correct 12 ms 1236 KB Output is correct
4 Correct 21 ms 1848 KB Output is correct
5 Runtime error 22 ms 3540 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -