Submission #212326

# Submission time Handle Problem Language Result Execution time Memory
212326 2020-03-22T17:17:37 Z MarcoMeijer Mechanical Doll (IOI18_doll) C++14
37 / 100
212 ms 11420 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, s;
vi c, x, y, a, state;

int LOG2(int X) {
  RE(i,30) if((1<<i) >= X) return i;
}
int createTriangle(int size) {
  if(size == 0) return 0;
  int i= s;
  s++;
  int id= -s;
  x.pb(0);
  y.pb(0);
  state.pb(0);
  int nx = createTriangle(size-1);
  int ny = createTriangle(size-1);
  x[i] = nx;
  y[i] = ny;
  return id;
}
void setTriangle(int u, int value) {
  u = -1-u;
  if(state[u]) {
    if(y[u] == 0) y[u] = value;
    else setTriangle(y[u], value);
  } else {
    if(x[u] == 0) x[u] = value;
    else setTriangle(x[u], value);
  }
  state[u] = !state[u];
}

void create_circuit(int m, vi A) {
  a = A;
  s = 0;
  a.push_back(0);
  n = a.size();
  c.clear(); x.clear(); y.clear(); state.clear();

  int l2 = LOG2(n);
  int root = createTriangle(l2);
  int empty = (1<<l2) - n;
  RE(i,empty) setTriangle(root,root);
  RE(i,n) setTriangle(root, a[i]);

  c.resize(m+1);
  RE(i,m+1) c[i] = root;

  answer(c, x, y);
}

Compilation message

doll.cpp: In function 'int LOG2(int)':
doll.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 203 ms 9248 KB Output is partially correct
3 Partially correct 182 ms 9176 KB Output is partially correct
4 Partially correct 190 ms 10856 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 203 ms 9248 KB Output is partially correct
3 Partially correct 182 ms 9176 KB Output is partially correct
4 Partially correct 190 ms 10856 KB Output is partially correct
5 Partially correct 176 ms 11420 KB Output is partially correct
6 Partially correct 175 ms 11344 KB Output is partially correct
7 Partially correct 181 ms 11404 KB Output is partially correct
8 Partially correct 176 ms 11164 KB Output is partially correct
9 Partially correct 212 ms 9280 KB Output is partially correct
10 Partially correct 183 ms 11280 KB Output is partially correct
11 Partially correct 209 ms 10908 KB Output is partially correct
12 Partially correct 177 ms 9412 KB Output is partially correct
13 Partially correct 210 ms 9656 KB Output is partially correct
14 Partially correct 164 ms 9784 KB Output is partially correct
15 Partially correct 182 ms 10012 KB Output is partially correct
16 Partially correct 5 ms 588 KB Output is partially correct
17 Correct 91 ms 6832 KB Output is correct
18 Partially correct 205 ms 9404 KB Output is partially correct
19 Partially correct 198 ms 9420 KB Output is partially correct
20 Partially correct 180 ms 11088 KB Output is partially correct
21 Partially correct 191 ms 10908 KB Output is partially correct
22 Partially correct 163 ms 10896 KB Output is partially correct