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;
void answer(vector<int> C, vector<int> X, vector<int> Y);
int n, m;
vector<int> a, b;
vector<int> x, y;
void build(int p, int l, int r) {
if (l == r-1) {
if (b[l] < n) {
x[p-1] = a[b[l]];
}
else x[p-1] = -1;
if (b[r] < n) {
y[p-1] = a[b[r]];
}
else if (b[r] == b.size() - 1) y[p-1] = 0;
else y[p-1] = -1;
}
else {
x[p-1] = -(2*p);
y[p-1] = -(2*p+1);
int mid = (l+r)/2;
build(2*p, l, mid);
build(2*p+1, mid+1, r);
}
}
void create_circuit(int M, vector<int> A) {
a = A; m = M;
n = A.size();
b.push_back(0);
a.push_back(0);
while (b.size() < n+1) {
vector<int> temp;
for (int i = 0; i < b.size(); i++) {
temp.push_back(b[i]);
temp.push_back(b[i] + b.size());
}
b = temp;
}
/*for (int i = 0; i < b.size(); i++) {
printf("%d ", b[i]);
}
printf("\n");
for (int i = 0; i < a.size(); i++) {
printf("%d ", a[i]);
}
printf("\n");*/
vector<int> C(M + 1);
for (int i = 0; i <= m; i++) {
C[i] = -1;
}
x.resize(b.size()-1); y.resize(b.size()-1);
build(1, 0, b.size()-1);
answer(C, x, y);
}
Compilation message (stderr)
doll.cpp: In function 'void build(int, int, int)':
doll.cpp:20:17: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | else if (b[r] == b.size() - 1) y[p-1] = 0;
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:37:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | while (b.size() < n+1) {
| ~~~~~~~~~^~~~~
doll.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for (int i = 0; i < b.size(); i++) {
| ~~^~~~~~~~~~
# | 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... |