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 cr2(int la, vector<int> &X, vector<int> &Y, vector<int> &cur){
vector<int> p1, p2;
for(int i = 0; i < cur.size(); ++i){
if(i&1)p2.push_back(cur[i]);
else p1.push_back(cur[i]);
}
if(p1.size() == 1){
X.push_back(p1[0]);
Y.push_back(0);
}
else{
X.push_back(-la-1);
Y.push_back(0);
cr2(la+1,X,Y,p1);
}
if(p2.size() == 1){
Y[la-1] = p2[0];
}
else{
Y[la-1] = -(X.size()+1);
cr2(X.size()+1,X,Y,p2);
}
return;
}
void create(int in, vector<int> &X, vector<int> &Y, vector<vector<int>> &v, vector<int> &c){
if(v[in].size() == 1){c[in] = v[in][0];return;}
if(!v[in].size())return;
c[in] = -(X.size()+1);
cr2(X.size()+1,X,Y,v[in]);
}
void create_circuit(int m, vector<int> A) {
int n = A.size();
vector<int> C(m + 1,0);
vector<vector<int>> v(m+1);
for(int i = 0; i < n; ++i){
if(!i)v[0].push_back(A[i]);
else v[A[i-1]].push_back(A[i]);
if(i == n-1)v[A[i]].push_back(0);
}
vector<int> X, Y;
for(int i = 0; i <= n; ++i){
create(i,X,Y,v,C);
}
answer(C,X,Y);
}
Compilation message (stderr)
doll.cpp: In function 'void cr2(int, std::vector<int>&, std::vector<int>&, std::vector<int>&)':
doll.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for(int i = 0; i < cur.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... |