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;
using ll = long long;
void create_circuit(int m, std::vector<int> a) {
int p = 0;
a.push_back (0);
vector < int > c (m + 1, -1), x, y;
x.reserve (a.size () * 2);
y.reserve (a.size () * 2);
int vt = 1, vtt = 0;
while (vt < a.size ()) vt *= 2, ++vtt;
vector < int > v (vt, -1);
for (int i = 0; i < a.size (); ++i)
{
int j = vt - a.size () + i, k = 0;
for (int i = 0; i < vtt; ++i) k = k * 2 + j % 2, j /= 2;
v[k] = a[i];
}
auto f = [&] (auto &self, int l, int r) -> int
{
if (l + 1 == r) return v[l];
int m = (l + r) / 2;
int i = x.size ();
x.push_back (0), y.push_back (0);
x[i] = self (self, l, m);
y[i] = self (self, m, r);
return -(i + 1);
};
c[0] = f (f, 0, vt);
answer (c, x, y);
}
Compilation message (stderr)
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:13:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | while (vt < a.size ()) vt *= 2, ++vtt;
| ~~~^~~~~~~~~~~
doll.cpp:15:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for (int i = 0; i < a.size (); ++i)
| ~~^~~~~~~~~~~
doll.cpp:7:7: warning: unused variable 'p' [-Wunused-variable]
7 | int p = 0;
| ^
# | 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... |