Submission #172983

# Submission time Handle Problem Language Result Execution time Memory
172983 2020-01-02T22:18:45 Z nobik Mechanical Doll (IOI18_doll) C++14
6 / 100
96 ms 11052 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

int BuildTree(const vector<int>& outs, vector<int>& x, vector<int>& y) {
  if (outs.size() == 1) {
    return outs[0];
  }

  vector<int> left, right;
  for (int i = 0; i < (int) outs.size(); ++i) {
    if (i % 2 == 0)
      left.push_back(outs[i]);
    else
      right.push_back(outs[i]);
  }

  int id_left = BuildTree(left, x, y);
  int id_right = BuildTree(right, x, y);
  x.push_back(id_left);
  y.push_back(id_right);
  return -(int)x.size();
}

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

  vector<vector<int>> outs(M + 1);
  outs[0].push_back(A[0]);


  std::vector<int> C(M + 1);
  vector<int> X, Y;
  for (int i = 0; i < n; ++i) {
    if (i + 1 < n)
      outs[A[i]].push_back(A[i + 1]);
  }

  outs[A[n - 1]].push_back(0);

  for (int i = 0; i < M + 1; ++i) {
    if (!outs[i].empty())
      C[i] = BuildTree(outs[i], X, Y);
  }

  answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 33 ms 6348 KB Output is correct
3 Correct 26 ms 5176 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 15 ms 3788 KB Output is correct
6 Correct 51 ms 7732 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 33 ms 6348 KB Output is correct
3 Correct 26 ms 5176 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 15 ms 3788 KB Output is correct
6 Correct 51 ms 7732 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 74 ms 7248 KB Output is correct
9 Correct 72 ms 8612 KB Output is correct
10 Correct 96 ms 11052 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 33 ms 6348 KB Output is correct
3 Correct 26 ms 5176 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 15 ms 3788 KB Output is correct
6 Correct 51 ms 7732 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 74 ms 7248 KB Output is correct
9 Correct 72 ms 8612 KB Output is correct
10 Correct 96 ms 11052 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Incorrect 95 ms 9372 KB state 'Y'
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -