Submission #962092

# Submission time Handle Problem Language Result Execution time Memory
962092 2024-04-13T06:57:07 Z yellowtoad Mechanical Doll (IOI18_doll) C++17
100 / 100
98 ms 12888 KB
#include "doll.h"
#include <iostream>
using namespace std;

int n, idx, b[500010], cnt, cnnt;
vector<int> a, edge[2];

void run(int id, int x, int y) {
  int mid = (x+y)/2;
  if (b[id] == 0) {
    b[id] = 1;
    if (n < mid+1) {
      edge[0][id-1] = -1;
      return;
    }
    if (mid+1 == y) {
      edge[0][id-1] = a[cnnt++];
      return;
    }
    if (edge[0][id-1] == 1e9) {
      edge[0].push_back(1e9);
      edge[1].push_back(1e9);
      edge[0][id-1] = --cnt;
    }
    run(-edge[0][id-1],mid+1,y);
  } else {
    b[id] = 0;
    if (mid+1 == y) {
      edge[1][id-1] = a[cnnt++];
      return;
    }
    if (edge[1][id-1] == 1e9) {
      edge[0].push_back(1e9);
      edge[1].push_back(1e9);
      edge[1][id-1] = --cnt;
    }
    run(-edge[1][id-1],x,mid);
  }
}

void create_circuit(int m, std::vector<int> A) {
  a = A;
  a.push_back(0);
  n = a.size();
  vector<int> C(m+1,-1);
  while ((1<<(idx+1)) < n) idx++;
  edge[0].push_back(1e9);
  edge[1].push_back(1e9);
  cnt = -1;
  for (int i = 1; i <= (1<<(idx+1)); i++) run(1,1,(1<<(idx+1)));
  answer(C,edge[0],edge[1]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 35 ms 4912 KB Output is correct
3 Correct 26 ms 5200 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 1472 KB Output is correct
6 Correct 49 ms 7308 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 35 ms 4912 KB Output is correct
3 Correct 26 ms 5200 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 1472 KB Output is correct
6 Correct 49 ms 7308 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 50 ms 8568 KB Output is correct
9 Correct 54 ms 9080 KB Output is correct
10 Correct 89 ms 12888 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 35 ms 4912 KB Output is correct
3 Correct 26 ms 5200 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 1472 KB Output is correct
6 Correct 49 ms 7308 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 50 ms 8568 KB Output is correct
9 Correct 54 ms 9080 KB Output is correct
10 Correct 89 ms 12888 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 74 ms 12512 KB Output is correct
15 Correct 52 ms 8044 KB Output is correct
16 Correct 85 ms 12168 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 352 KB Output is correct
20 Correct 76 ms 12596 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 444 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 448 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 352 KB Output is correct
7 Correct 1 ms 356 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 46 ms 7064 KB Output is correct
3 Correct 48 ms 7036 KB Output is correct
4 Correct 64 ms 10804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 46 ms 7064 KB Output is correct
3 Correct 48 ms 7036 KB Output is correct
4 Correct 64 ms 10804 KB Output is correct
5 Correct 72 ms 12172 KB Output is correct
6 Correct 80 ms 12060 KB Output is correct
7 Correct 76 ms 11836 KB Output is correct
8 Correct 69 ms 11576 KB Output is correct
9 Correct 44 ms 7156 KB Output is correct
10 Correct 68 ms 11316 KB Output is correct
11 Correct 70 ms 11176 KB Output is correct
12 Correct 60 ms 7280 KB Output is correct
13 Correct 46 ms 7824 KB Output is correct
14 Correct 47 ms 7796 KB Output is correct
15 Correct 47 ms 8096 KB Output is correct
16 Correct 3 ms 600 KB Output is correct
17 Correct 62 ms 7760 KB Output is correct
18 Correct 54 ms 7304 KB Output is correct
19 Correct 50 ms 7444 KB Output is correct
20 Correct 98 ms 11256 KB Output is correct
21 Correct 78 ms 11092 KB Output is correct
22 Correct 81 ms 11220 KB Output is correct