Submission #212334

# Submission time Handle Problem Language Result Execution time Memory
212334 2020-03-22T17:26:53 Z MarcoMeijer Mechanical Doll (IOI18_doll) C++14
37 / 100
258 ms 11264 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 = (0-s);
  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 = (0-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);
  }
  if(state[u] == 1) state[u] = 0;
  else state[u] = 1;
}

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 mx=3e5;
  x.resize(mx);
  y.resize(mx);
  state.resize(mx);
  RE(i,mx) state[i]=0;

  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;
  x.resize(s);
  y.resize(s);

  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 4 ms 3788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 3788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 3788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 3788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 3788 KB Output is partially correct
2 Partially correct 182 ms 9456 KB Output is partially correct
3 Partially correct 160 ms 9520 KB Output is partially correct
4 Partially correct 167 ms 10256 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 3788 KB Output is partially correct
2 Partially correct 182 ms 9456 KB Output is partially correct
3 Partially correct 160 ms 9520 KB Output is partially correct
4 Partially correct 167 ms 10256 KB Output is partially correct
5 Partially correct 187 ms 11264 KB Output is partially correct
6 Partially correct 201 ms 10980 KB Output is partially correct
7 Partially correct 196 ms 11164 KB Output is partially correct
8 Partially correct 193 ms 10752 KB Output is partially correct
9 Partially correct 186 ms 9452 KB Output is partially correct
10 Partially correct 258 ms 10652 KB Output is partially correct
11 Partially correct 208 ms 10296 KB Output is partially correct
12 Partially correct 156 ms 9712 KB Output is partially correct
13 Partially correct 188 ms 10084 KB Output is partially correct
14 Partially correct 173 ms 10212 KB Output is partially correct
15 Partially correct 206 ms 10340 KB Output is partially correct
16 Partially correct 6 ms 4044 KB Output is partially correct
17 Correct 89 ms 8352 KB Output is correct
18 Partially correct 165 ms 9652 KB Output is partially correct
19 Partially correct 194 ms 9704 KB Output is partially correct
20 Partially correct 188 ms 10524 KB Output is partially correct
21 Partially correct 172 ms 10344 KB Output is partially correct
22 Partially correct 180 ms 10384 KB Output is partially correct