#include <bits/stdc++.h>
#include "doll.h"
#warning That's not FB, that's my FB
using namespace std;
int n,m;
vector<int> a;
vector<vector<int>> pos;
vector<int> unde;
int cur = 1;
vector<int> c, x, y;
int ngl, kgl, pgl;
void build(int nume, int l, int r)
{
int mij = (l + r) / 2;
if (mij <= pgl)
x[-nume - 1] = -1;
else
{
if (l != mij)
{
x[-nume - 1] = -cur;
cur++;
x.push_back(0);
y.push_back(0);
build(x[-nume - 1], l, mij);
}
else
{
//int pz = pos[ngl][unde[ngl]] + 1;
//unde[ngl]++;
x[-nume - 1] = 3 * n;
}
}
if (mij + 1 != r)
{
y[-nume - 1] = -cur;
cur++;
x.push_back(0);
y.push_back(0);
build(y[-nume - 1], mij + 1, r);
}
else
{
//int pz = pos[ngl][unde[ngl]] + 1;
//unde[ngl]++;
y[-nume - 1] = 3 * n;
}
}
void build_sgt(int nod)
{
cur = 2;
kgl = __lg(n);
if ((1 << kgl) < n)
kgl++;
pgl = (1 << kgl) - (int)n;
build(nod, 1, (1 << kgl));
}
int cr = 0;
vector<int> how;
void gogo(int nod)
{
//cout << nod << endl;
if (nod == 0)
return;
if (nod >= 1)
{
cr++;
gogo(c[nod]);
return;
}
//cout << x[-nod - 1] << ' ' << y[-nod - 1] << ' ' << how[-nod - 1] << endl;
if (how[-nod - 1] == 0)
{
how[-nod - 1] = 1;
if (x[-nod - 1] > 2 * n)
{
x[-nod - 1] = a[cr];
//cr++;
}
gogo(x[-nod - 1]);
}
else
{
how[-nod - 1] = 0;
if (y[-nod - 1] > 2 * n)
{
y[-nod - 1] = a[cr];
//cr++;
}
gogo(y[-nod - 1]);
}
}
void create_circuit(int M, vector<int> A)
{
A.push_back(0);
n = A.size();
a = A;
m = M;
pos.resize(m + 1);
unde.resize(m + 1);
for (int i = 0; i < a.size(); i++)
pos[a[i]].push_back(i);
a.push_back(0);
c.resize(m + 1);
for (int i = 0; i <= m; i++)
c[i] = -1;
x.push_back(0);
y.push_back(0);
how.resize(2 * n);
build_sgt(-1);
gogo(-1);
/*for (auto it : c)
cout << it << ' ';
cout << endl;
for (auto it : x)
cout << it << ' ';
cout << endl;
for (auto it : y)
cout << it << ' ';
cout << endl;*/
answer(c, x, y);
}
Compilation message
doll.cpp:3:2: warning: #warning That's not FB, that's my FB [-Wcpp]
3 | #warning That's not FB, that's my FB
| ^~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:110:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
110 | for (int i = 0; i < a.size(); i++)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
47 ms |
10320 KB |
Output is correct |
3 |
Correct |
34 ms |
9204 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
4188 KB |
Output is correct |
6 |
Correct |
65 ms |
13780 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
47 ms |
10320 KB |
Output is correct |
3 |
Correct |
34 ms |
9204 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
4188 KB |
Output is correct |
6 |
Correct |
65 ms |
13780 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
76 ms |
13568 KB |
Output is correct |
9 |
Correct |
68 ms |
15236 KB |
Output is correct |
10 |
Correct |
119 ms |
20016 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
47 ms |
10320 KB |
Output is correct |
3 |
Correct |
34 ms |
9204 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
4188 KB |
Output is correct |
6 |
Correct |
65 ms |
13780 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
76 ms |
13568 KB |
Output is correct |
9 |
Correct |
68 ms |
15236 KB |
Output is correct |
10 |
Correct |
119 ms |
20016 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
104 ms |
17428 KB |
Output is correct |
15 |
Correct |
63 ms |
11084 KB |
Output is correct |
16 |
Correct |
112 ms |
16176 KB |
Output is correct |
17 |
Correct |
0 ms |
436 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
99 ms |
18172 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
76 ms |
9036 KB |
Output is correct |
3 |
Correct |
58 ms |
8524 KB |
Output is correct |
4 |
Correct |
84 ms |
13344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
76 ms |
9036 KB |
Output is correct |
3 |
Correct |
58 ms |
8524 KB |
Output is correct |
4 |
Correct |
84 ms |
13344 KB |
Output is correct |
5 |
Correct |
97 ms |
16436 KB |
Output is correct |
6 |
Correct |
125 ms |
15632 KB |
Output is correct |
7 |
Correct |
100 ms |
15924 KB |
Output is correct |
8 |
Correct |
121 ms |
15156 KB |
Output is correct |
9 |
Correct |
57 ms |
8784 KB |
Output is correct |
10 |
Correct |
90 ms |
15008 KB |
Output is correct |
11 |
Correct |
87 ms |
14588 KB |
Output is correct |
12 |
Correct |
62 ms |
9664 KB |
Output is correct |
13 |
Correct |
75 ms |
10468 KB |
Output is correct |
14 |
Correct |
65 ms |
10588 KB |
Output is correct |
15 |
Correct |
79 ms |
10828 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
50 ms |
9556 KB |
Output is correct |
18 |
Correct |
55 ms |
9372 KB |
Output is correct |
19 |
Correct |
57 ms |
9420 KB |
Output is correct |
20 |
Correct |
106 ms |
14192 KB |
Output is correct |
21 |
Correct |
94 ms |
14136 KB |
Output is correct |
22 |
Correct |
86 ms |
13928 KB |
Output is correct |