Submission #958396

# Submission time Handle Problem Language Result Execution time Memory
958396 2024-04-05T18:08:40 Z AkibAzmain Mechanical Doll (IOI18_doll) C++17
53 / 100
94 ms 14668 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void create_circuit(int m, std::vector<int> a) {
  int p = 0;
  a.push_back (0);
  vector < vector < int > > adj (m + 1);
  for (auto &x : a) adj[p].push_back (x), p = x;
  vector < int > c (m + 1), x, y;
  x.reserve (a.size () * 2);
  y.reserve (a.size () * 2);
  for (int i = 0; i <= m; ++i)
    {
      if (adj[i].empty ()) continue;
      if (adj[i].size () == 1)
        {
          c[i] = adj[i][0];
          continue;
        }
      int vt = 1, vtt = 0;
      while (vt < adj[i].size ()) vt *= 2, ++vtt;
      vector < int > v (vt, -((int) x.size () + 1));
      for (int j = 0; j < adj[i].size (); ++j)
        {
          int k = vt - adj[i].size () + j, q = 0;
          for (int p = 0; p < vtt; ++p) q = q * 2 + k % 2, k /= 2;
          v[q] = adj[i][j];
        }
      auto f = [&] (auto &self, int l, int r) -> int
      {
        if (l + 1 == r) return v[l];
        int m = (l + r) / 2;
        x.push_back (0), y.push_back (0);
        int i = x.size () - 1;
        x[i] = self (self, l, m);
        y[i] = self (self, m, r);
        return -(i + 1);
      };
      c[i] = f (f, 0, vt);
    }
  answer (c, x, y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |       while (vt < adj[i].size ()) vt *= 2, ++vtt;
      |              ~~~^~~~~~~~~~~~~~~~
doll.cpp:25:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |       for (int j = 0; j < adj[i].size (); ++j)
      |                       ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 19 ms 6444 KB Output is correct
3 Correct 15 ms 5208 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 23 ms 7892 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 19 ms 6444 KB Output is correct
3 Correct 15 ms 5208 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 23 ms 7892 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 31 ms 7256 KB Output is correct
9 Correct 33 ms 8532 KB Output is correct
10 Correct 63 ms 10824 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 19 ms 6444 KB Output is correct
3 Correct 15 ms 5208 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 23 ms 7892 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 31 ms 7256 KB Output is correct
9 Correct 33 ms 8532 KB Output is correct
10 Correct 63 ms 10824 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 63 ms 11072 KB Output is correct
15 Correct 33 ms 6740 KB Output is correct
16 Correct 50 ms 10304 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 60 ms 12196 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 424 KB Output is partially correct
2 Correct 30 ms 5464 KB Output is correct
3 Partially correct 55 ms 7948 KB Output is partially correct
4 Partially correct 56 ms 8772 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 424 KB Output is partially correct
2 Correct 30 ms 5464 KB Output is correct
3 Partially correct 55 ms 7948 KB Output is partially correct
4 Partially correct 56 ms 8772 KB Output is partially correct
5 Partially correct 70 ms 12096 KB Output is partially correct
6 Partially correct 88 ms 14148 KB Output is partially correct
7 Partially correct 83 ms 13764 KB Output is partially correct
8 Partially correct 94 ms 14144 KB Output is partially correct
9 Partially correct 54 ms 9560 KB Output is partially correct
10 Partially correct 86 ms 14668 KB Output is partially correct
11 Partially correct 77 ms 14368 KB Output is partially correct
12 Partially correct 50 ms 9560 KB Output is partially correct
13 Partially correct 49 ms 9304 KB Output is partially correct
14 Partially correct 49 ms 9136 KB Output is partially correct
15 Partially correct 50 ms 9036 KB Output is partially correct
16 Partially correct 2 ms 604 KB Output is partially correct
17 Partially correct 57 ms 8180 KB Output is partially correct
18 Partially correct 49 ms 8024 KB Output is partially correct
19 Partially correct 43 ms 8532 KB Output is partially correct
20 Partially correct 59 ms 11080 KB Output is partially correct
21 Partially correct 69 ms 12872 KB Output is partially correct
22 Partially correct 55 ms 10572 KB Output is partially correct