Submission #585942

# Submission time Handle Problem Language Result Execution time Memory
585942 2022-06-29T15:09:10 Z Vanilla Mechanical Doll (IOI18_doll) C++17
100 / 100
137 ms 13636 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int maxn = 2e5 + 2;
int state [maxn * 2]; 
vector<int> x(2 * maxn), y(2 * maxn);
int n, k, depth, ct;

int dfs(int l, int r) {
	if (l >= n) return -1;
  if (r - l > 1) {
    int mid = (l + r) / 2, u = ct++;
    y[u] = dfs(l, mid);
    x[u] = dfs(mid, r);
    return -u-1;
  }
  return 1;
}
 
void create_circuit(int m, vector<int> a) {
  a.push_back(0);
  n = a.size();
  vector<int> c(m + 1, -1);
  for (int i = 0; i < 30; i++){
    if ((1 << i) >= n) {
      depth = i;
      break;
    }
  }
  k = (1 << depth);
  dfs(0, k);
  for (int i: a) {
    int node = 0;
    while (node >= 0) {
      int &next = state[node] ? y[node]: x[node];
      state[node]^=1;
      if (next >= 0) next = i, node = -1;
      node = -next-1;
    }
  }
  x.resize(ct);
  y.resize(ct);
  answer(c, x, y);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 45 ms 6856 KB Output is correct
3 Correct 40 ms 7096 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 10 ms 4608 KB Output is correct
6 Correct 61 ms 9208 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 45 ms 6856 KB Output is correct
3 Correct 40 ms 7096 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 10 ms 4608 KB Output is correct
6 Correct 61 ms 9208 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 82 ms 9996 KB Output is correct
9 Correct 78 ms 10612 KB Output is correct
10 Correct 113 ms 13636 KB Output is correct
11 Correct 3 ms 3412 KB Output is correct
12 Correct 3 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 45 ms 6856 KB Output is correct
3 Correct 40 ms 7096 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 10 ms 4608 KB Output is correct
6 Correct 61 ms 9208 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 82 ms 9996 KB Output is correct
9 Correct 78 ms 10612 KB Output is correct
10 Correct 113 ms 13636 KB Output is correct
11 Correct 3 ms 3412 KB Output is correct
12 Correct 3 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Correct 132 ms 13120 KB Output is correct
15 Correct 73 ms 9484 KB Output is correct
16 Correct 137 ms 12932 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 118 ms 13344 KB Output is correct
21 Correct 2 ms 3412 KB Output is correct
22 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 3 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 71 ms 8544 KB Output is correct
3 Correct 76 ms 8592 KB Output is correct
4 Correct 105 ms 11468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 71 ms 8544 KB Output is correct
3 Correct 76 ms 8592 KB Output is correct
4 Correct 105 ms 11468 KB Output is correct
5 Correct 112 ms 12752 KB Output is correct
6 Correct 124 ms 12492 KB Output is correct
7 Correct 114 ms 12536 KB Output is correct
8 Correct 113 ms 12252 KB Output is correct
9 Correct 67 ms 8628 KB Output is correct
10 Correct 107 ms 12120 KB Output is correct
11 Correct 107 ms 11860 KB Output is correct
12 Correct 69 ms 8772 KB Output is correct
13 Correct 82 ms 9280 KB Output is correct
14 Correct 73 ms 9284 KB Output is correct
15 Correct 76 ms 9412 KB Output is correct
16 Correct 3 ms 3668 KB Output is correct
17 Correct 64 ms 8852 KB Output is correct
18 Correct 69 ms 8792 KB Output is correct
19 Correct 70 ms 8876 KB Output is correct
20 Correct 106 ms 11972 KB Output is correct
21 Correct 110 ms 11712 KB Output is correct
22 Correct 103 ms 11768 KB Output is correct