Submission #292536

#TimeUsernameProblemLanguageResultExecution timeMemory
292536theStaticMindMechanical Doll (IOI18_doll)C++14
37 / 100
182 ms13016 KiB
#include<bits/stdc++.h>
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
using namespace std;
#include "doll.h"

int n;
vector<int> C, X(1, 1e9), Y(1, 1e9);
vector<int> vis(1e6, 0);
int l;

int new_node(){
      X.pb(1e9);
      Y.pb(1e9);
      return sz(X) - 1;
}

int build(int x, int d, int v){
      if(d == l) return v;

      if(x == 1e9) x = new_node();
      else x = -x - 1;
      vis[x]++;
      if(vis[x] % 2){
            int k = build(X[x], d + 1, v);
            X[x] = k;

      }
      else{
            int k = build(Y[x], d + 1, v);
            Y[x] = k;
      }
      return -x - 1;
}

void create_circuit(int M, std::vector<int> A) {
      n = A.size();
      C = vector<int>(M + 1, -1);

      l = ceil(log2(n + 1));

      for(auto x : A){
            build(-1, 0, x);
      }
      for(int i = n + 1; i < (1 << l); i++) build(-1, 0, -1);
      build(-1, 0, 0);

      answer(C, X, Y);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...