#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
int adja[400002], adjb[400002], sw = 1, tot, state[400002];
void build(int p, int st, int dr)
{
int mid = (st + dr) / 2;
if(st + 1 == dr)
{
if(tot <= mid)
adja[p] = 1;
return;
}
++sw;
adjb[p] = sw;
build(sw, st, mid);
if(tot > mid)
{
++sw;
adja[p] = sw;
build(sw, mid+1, dr);
}
else
adja[p] = 1;
}
void dfs(int nod, int val)
{
state[nod] ^= 1;
if(!state[nod])
{
if(adjb[nod])
dfs(adjb[nod], val);
else
adjb[nod] = val;
}
else
{
if(adja[nod])
dfs(adja[nod], val);
else
adja[nod] = val;
}
}
void create_circuit(int M, vector<int> A)
{
int N = A.size();
vector<int> C;
C.push_back(A[0]);
for(int i = 1; i <= M; ++i)
C.push_back(-1);
A.push_back(0);
int sz = 1;
while(sz * 2 <= (int) A.size() - 1)
sz *= 2;
sz *= 2;
tot = A.size();
build(1, 1, sz);
for(int i = 0; i < A.size(); ++i)
dfs(1, -A[i]);
vector<int> X(sw), Y(sw);
for(int k = 0; k < sw; ++k)
{
X[k] = -adja[k];
Y[k] = -adjb[k];
}
answer(C, X, Y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | for(int i = 0; i < A.size(); ++i)
| ~~^~~~~~~~~~
doll.cpp:50:9: warning: unused variable 'N' [-Wunused-variable]
50 | int N = A.size();
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |