#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;
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] = c[ngl];
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][l - pgl - 1] + 1;
x[-nume - 1] = a[pz];
}
}
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][r - pgl - 1] + 1;
y[-nume - 1] = a[pz];
}
}
void build_sgt(int nod)
{
c[nod] = -cur;
cur++;
x.push_back(0);
y.push_back(0);
ngl = nod;
kgl = __lg(pos[nod].size());
if ((1 << kgl) < pos[nod].size())
kgl++;
pgl = (1 << kgl) - (int)pos[nod].size();
build(c[nod], 1, (1 << kgl));
}
void create_circuit(int M, vector<int> A)
{
n = A.size();
a = A;
m = M;
pos.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);
c[0] = a[0];
for (int i = 1; i <= m; i++)
{
if (pos[i].empty())
c[i] = 0;
else if (pos[i].size() == 1)
c[i] = a[pos[i][0] + 1];
else
build_sgt(i);
}
/*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 build_sgt(int)':
doll.cpp:60:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | if ((1 << kgl) < pos[nod].size())
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for (int i = 0; i < a.size(); i++)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
17 ms |
7000 KB |
Output is correct |
3 |
Correct |
13 ms |
5976 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
6 ms |
3932 KB |
Output is correct |
6 |
Correct |
20 ms |
9028 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
17 ms |
7000 KB |
Output is correct |
3 |
Correct |
13 ms |
5976 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
6 ms |
3932 KB |
Output is correct |
6 |
Correct |
20 ms |
9028 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
32 ms |
9548 KB |
Output is correct |
9 |
Correct |
31 ms |
10660 KB |
Output is correct |
10 |
Correct |
43 ms |
14644 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
17 ms |
7000 KB |
Output is correct |
3 |
Correct |
13 ms |
5976 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
6 ms |
3932 KB |
Output is correct |
6 |
Correct |
20 ms |
9028 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
32 ms |
9548 KB |
Output is correct |
9 |
Correct |
31 ms |
10660 KB |
Output is correct |
10 |
Correct |
43 ms |
14644 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
56 ms |
15664 KB |
wrong motion |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
27 ms |
7528 KB |
Output is correct |
3 |
Correct |
25 ms |
7144 KB |
Output is correct |
4 |
Correct |
36 ms |
10660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
27 ms |
7528 KB |
Output is correct |
3 |
Correct |
25 ms |
7144 KB |
Output is correct |
4 |
Correct |
36 ms |
10660 KB |
Output is correct |
5 |
Incorrect |
60 ms |
15492 KB |
wrong motion |
6 |
Halted |
0 ms |
0 KB |
- |