# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
75054 | KieranHorgan | Mechanical Doll (IOI18_doll) | C++17 | 74 ms | 19456 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 "doll.h"
#include <bits/stdc++.h>
using namespace std;
pair<int, int> exits[400005];
vector<int> C, X, Y;
vector<int> afterInList[400005];
int nextSwitchIdx = -1;
int build(int i, vector<int> cur) {
if(cur.size() == 1) {
return cur[0];
}
if(X.size() < abs(i)) {
X.resize(abs(i));
Y.resize(abs(i));
}
vector<int> nextCur;
for(int i = 0; i < cur.size(); i+=2)
nextCur.push_back(cur[i]);
X[i] = build(nextSwitchIdx--, nextCur);
nextCur.clear();
for(int i = 1; i < cur.size(); i+=2)
nextCur.push_back(cur[i]);
Y[i] = build(nextSwitchIdx--, nextCur);
return i;
}
void create_circuit(int M, vector<int> A) {
int N = A.size();
C.assign(M+1, 0);
afterInList[0].push_back(A[0]);
for(int i = 0; i+1 < N; i++)
afterInList[A[i]].push_back(A[i+1]);
afterInList[A.back()].push_back(0);
for(int i = 0; i <= M; i++) {
if(afterInList[i].empty())
continue;
C[i] = build(i, afterInList[i]);
// cerr << i << ": " << C[i] << endl;
}
// cerr << X.size() << endl;
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... |