Submission #620083

# Submission time Handle Problem Language Result Execution time Memory
620083 2022-08-02T22:13:50 Z Mamedov Mechanical Doll (IOI18_doll) C++17
53 / 100
99 ms 15396 KB
#pragma GCC optimize ("O3")
#include "doll.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define piii pair<pii, int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define f first
#define s second
#define oo 1000000001
#define eb emplace_back
#define pb push_back
#define mpr make_pair
#define size(v) (int)v.size()
#define ln '\n'
#define ull unsigned long long
#define ll long long
#define all(v) v.begin(), v.end()

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void create_circuit(int M, vi A) {
  int N = size(A);
  A.eb(0);
  vvi g(M + 1);
  for (int i = 0; i < N; ++i) {
    g[A[i]].eb(A[i + 1]);
  }
  vi C(M + 1, 0), X, Y;
  int S = 0;
  C[0] = A[0];
  for (int i = 1; i <= M; ++i) {
    int ways = size(g[i]);
    if (ways) {
      int pins = 2;
      C[i] = -(S + pins - 1);
      X.eb(oo);
      Y.eb(oo);
      while (pins < ways) {
        for (int j = pins / 2; j < pins; ++j) {
          X[S + j - 1] = -(S + 2 * j);
          Y[S + j - 1] = -(S + 2 * j + 1);
          X.eb(oo);
          Y.eb(oo);
          X.eb(oo);
          Y.eb(oo);
        }
        pins *= 2;
      }
      vi order;
      order.eb(pins);
      int sz = 1;
      while (pins != 1) {
        pins /= 2;
        for (int j = 0; j < sz; ++j) {
          order.eb(order[j] + pins);
        }
        sz *= 2;
      }
      while (!order.empty()) {
        --ways;
        if ((order.back() & 1)) {
          Y[S + order.back() / 2 - 1] = (ways >= 0 ? g[i][ways] : -(S + 1));
        } else {
          X[S + order.back() / 2 - 1] = (ways >= 0 ? g[i][ways] : -(S + 1));
        }
        order.pop_back();
      }
      S = size(X);
    }
  }
  for (int i = 0; i < S; ++i) {
    if (Y[i] == oo) {
      Y[i] = X[i];
      X[i] = -(i + 1);
    }
  }
  answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 38 ms 8456 KB Output is correct
3 Correct 32 ms 7376 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3744 KB Output is correct
6 Correct 51 ms 10828 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 38 ms 8456 KB Output is correct
3 Correct 32 ms 7376 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3744 KB Output is correct
6 Correct 51 ms 10828 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 46 ms 8512 KB Output is correct
9 Correct 54 ms 11076 KB Output is correct
10 Correct 69 ms 12712 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 38 ms 8456 KB Output is correct
3 Correct 32 ms 7376 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3744 KB Output is correct
6 Correct 51 ms 10828 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 46 ms 8512 KB Output is correct
9 Correct 54 ms 11076 KB Output is correct
10 Correct 69 ms 12712 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 78 ms 12440 KB Output is correct
15 Correct 43 ms 7004 KB Output is correct
16 Correct 64 ms 10152 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 74 ms 12340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 300 KB Output is partially correct
2 Correct 35 ms 7236 KB Output is correct
3 Partially correct 57 ms 8936 KB Output is partially correct
4 Partially correct 63 ms 10168 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 300 KB Output is partially correct
2 Correct 35 ms 7236 KB Output is correct
3 Partially correct 57 ms 8936 KB Output is partially correct
4 Partially correct 63 ms 10168 KB Output is partially correct
5 Partially correct 92 ms 13572 KB Output is partially correct
6 Partially correct 99 ms 14124 KB Output is partially correct
7 Partially correct 93 ms 13956 KB Output is partially correct
8 Partially correct 93 ms 14300 KB Output is partially correct
9 Partially correct 57 ms 10144 KB Output is partially correct
10 Partially correct 90 ms 15396 KB Output is partially correct
11 Partially correct 90 ms 14560 KB Output is partially correct
12 Partially correct 57 ms 10184 KB Output is partially correct
13 Partially correct 61 ms 9212 KB Output is partially correct
14 Partially correct 59 ms 9112 KB Output is partially correct
15 Partially correct 59 ms 8948 KB Output is partially correct
16 Partially correct 2 ms 596 KB Output is partially correct
17 Partially correct 49 ms 8020 KB Output is partially correct
18 Partially correct 48 ms 8016 KB Output is partially correct
19 Partially correct 51 ms 8436 KB Output is partially correct
20 Partially correct 72 ms 11296 KB Output is partially correct
21 Partially correct 81 ms 12832 KB Output is partially correct
22 Partially correct 64 ms 10788 KB Output is partially correct