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;
const int N = 200100;
int dir[N*4], n, sz;
pair<int, int> pr[N];
void add(int v, int l, int r, int x){
if (l == r){
//cout << "kek " << v << ' ' << v/2-sz/2+1 << ' ' << x << endl;
if (v % 2 == 0)
pr[v/2-sz/2+1].first = x; else
pr[v/2-sz/2+1].second = x;
return;
}
int mid = (l+r)>>1;
if (dir[v] == 0)
add(v+v, l, mid, x); else
add(v+v+1, mid+1, r, x);
dir[v] ^= 1;
}
void create_circuit(int M, std::vector<int> A) {
n = A.size();
sz = 2;
while(sz < n)
sz += sz;
for (int i = 2; i <= n; i++){
add(1, 1, sz, A[i-1]);
}
for (int i = n+1; i < sz; i++){
add(1, 1, sz, -1);
}
add(1, 1, sz, 0);
vector <int> C, X, Y;
C.push_back(A[0]);
for (int i = 1; i <= M; i++)
C.push_back(-1);
for (int i = 1; i <= sz/2-1; i++){
X.push_back(-(i+i));
Y.push_back(-(i+i+1));
}
int kol = 0;
for (int i = 1; i <= sz/2; i++){
X.push_back(pr[i].first);
Y.push_back(pr[i].second);
}
answer(C, X, Y);
}
/**
4 4
1 2 1 3
*/
Compilation message (stderr)
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:46:9: warning: unused variable 'kol' [-Wunused-variable]
46 | int kol = 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... |