Submission #958618

# Submission time Handle Problem Language Result Execution time Memory
958618 2024-04-06T07:26:21 Z AkibAzmain Mechanical Doll (IOI18_doll) C++17
100 / 100
93 ms 10324 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void create_circuit(int m, std::vector<int> a) {
  a.push_back (0);
  int n = a.size (), vt = 1;
  while (vt < n) vt <<= 1;
  int ivt = 1e9, ust;
  vector < int > c (m + 1), x, y;
  auto f = [&] (auto &self, int l, int r) -> int
  {
    if (r <= 0) return ivt;
    if (l + 1 == r) return ust;
    int m = (l + r) / 2;
    int a = self (self, l, m), b = self (self, m, r);
    x.push_back (a), y.push_back (b);
    return -x.size ();
  };
  int fs = f (f, n - vt, n);
  for (auto &x : c) x = fs;
  for (auto &xx : x) if (xx == ivt) xx = fs;
  for (auto &xx : y) if (xx == ivt) xx = fs;
  int ai = 0;
  vector < bool > st (x.size ());
  for (int i = 0; i < n; ++i)
    for (int *i = &fs; ; st[-(*i + 1)] = !st[-(*i + 1)],
           i = st[-(*i + 1)] ? &x[-(*i + 1)] : &y[-(*i + 1)])
      if (*i == ust)
        {
           *i = a[ai++];
           break;
        }
  answer (c, x, y);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 32 ms 4432 KB Output is correct
3 Correct 36 ms 4572 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 8 ms 1372 KB Output is correct
6 Correct 52 ms 6828 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 32 ms 4432 KB Output is correct
3 Correct 36 ms 4572 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 8 ms 1372 KB Output is correct
6 Correct 52 ms 6828 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 57 ms 6764 KB Output is correct
9 Correct 61 ms 7524 KB Output is correct
10 Correct 91 ms 10324 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 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 32 ms 4432 KB Output is correct
3 Correct 36 ms 4572 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 8 ms 1372 KB Output is correct
6 Correct 52 ms 6828 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 57 ms 6764 KB Output is correct
9 Correct 61 ms 7524 KB Output is correct
10 Correct 91 ms 10324 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 84 ms 9700 KB Output is correct
15 Correct 57 ms 6244 KB Output is correct
16 Correct 82 ms 9352 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 88 ms 10064 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 59 ms 5244 KB Output is correct
3 Correct 53 ms 5244 KB Output is correct
4 Correct 81 ms 7940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 59 ms 5244 KB Output is correct
3 Correct 53 ms 5244 KB Output is correct
4 Correct 81 ms 7940 KB Output is correct
5 Correct 90 ms 9216 KB Output is correct
6 Correct 79 ms 8800 KB Output is correct
7 Correct 84 ms 8772 KB Output is correct
8 Correct 78 ms 8540 KB Output is correct
9 Correct 60 ms 5492 KB Output is correct
10 Correct 86 ms 8460 KB Output is correct
11 Correct 77 ms 7956 KB Output is correct
12 Correct 52 ms 5504 KB Output is correct
13 Correct 54 ms 5740 KB Output is correct
14 Correct 60 ms 5920 KB Output is correct
15 Correct 55 ms 5996 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 48 ms 6580 KB Output is correct
18 Correct 58 ms 5492 KB Output is correct
19 Correct 51 ms 5444 KB Output is correct
20 Correct 78 ms 8200 KB Output is correct
21 Correct 93 ms 8200 KB Output is correct
22 Correct 85 ms 8088 KB Output is correct