# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83467 | aquablitz11 | Mechanical Doll (IOI18_doll) | C++14 | 143 ms | 10460 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
vector<int> X, Y;
int get(int l, int r) {
X.push_back(l);
Y.push_back(r);
return -X.size();
}
int solve(vector<int> &A) {
vector<int> L, R;
bool diff = false;
for (int i = 0; i < A.size(); ++i) {
if (A[i] != A[0]) diff = true;
if (i%2==0) L.push_back(A[i]);
else R.push_back(A[i]);
}
if (!diff)
return A[0];
A.clear();
int l = solve(L);
int r = solve(R);
return get(l, r);
}
int rev(int n, int i) {
int val = 0;
while (n--) {
val <<= 1;
val |= i&1;
i >>= 1;
}
return val;
}
void create_circuit(int m, vector<int> A) {
A.push_back(0);
int n = A.size();
int k = 0;
while ((1<<k) < n) ++k;
vector<int> B(1<<k, 0);
for (int i = 0; i < n; ++i) {
int r = rev(k, (1<<k)-i-1);
B[r] = 1;
}
int c = 0;
for (int i = 0; i < (1<<k); ++i) {
if (B[i]) B[i] = A[c++];
else B[i] = m+1;
}
int u = solve(B);
for (int i = 0; i < X.size(); ++i) {
if (X[i] == m+1) X[i] = u;
if (Y[i] == m+1) Y[i] = u;
}
vector<int> C(m+1, u);
answer(C, X, Y);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |