#include "doll.h"
#include <iostream>
#include <vector>
using namespace std;
int n, m, s, cnt, idx;
vector<int> v[100010], xx, yy;
void create_circuit(int M, std::vector<int> a) {
n = a.size(); m = M;
vector<int> c(m+1), x, y;
c[0] = a[0];
a.push_back(0);
for (int i = 0; i < n; i++) v[a[i]].push_back(a[i+1]);
for (int i = 1; i <= m; i++) {
if (v[i].empty()) c[i] = 0;
else if (v[i].size() == 1) c[i] = v[i][0];
else {
xx.clear(); yy.clear();
xx.push_back(0); yy.push_back(0);
idx = 0;
while ((1<<(idx+1)) < v[i].size()) {
for (int j = 1; j <= (1<<idx); j++) {
xx.push_back(s-xx.size()*2);
yy.push_back(s-yy.size()*2-1);
}
idx++;
}
for (int j = 0; j < v[i].size()-1; j++) {
if (j%2 == 0) xx.push_back(v[i][j]);
else yy.push_back(v[i][j]);
}
for (int j = v[i].size(); j < (1<<(idx+1)); j++) {
if (j%2) xx.push_back(s-1);
else yy.push_back(s-1);
}
yy.push_back(v[i].back());
c[i] = s-1;
s -= (1<<(idx+1))-1;
for (int j = 1; j < xx.size(); j++) {
x.push_back(xx[j]);
y.push_back(yy[j]);
}
}
}
/*for (int i = 0; i <= m; i++) cout << c[i] << " ";
cout << endl;
for (int i = 0; i < x.size(); i++) cout << x[i] << " ";
cout << endl;
for (int i = 0; i < y.size(); i++) cout << y[i] << " ";
cout << endl;*/
answer(c,x,y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | while ((1<<(idx+1)) < v[i].size()) {
| ~~~~~~~~~~~~~^~~~~~~~~~~~~
doll.cpp:29:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int j = 0; j < v[i].size()-1; j++) {
| ~~^~~~~~~~~~~~~~~
doll.cpp:40:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for (int j = 1; j < xx.size(); j++) {
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
20 ms |
6484 KB |
Output is correct |
3 |
Correct |
15 ms |
5972 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
8 ms |
3744 KB |
Output is correct |
6 |
Correct |
23 ms |
7636 KB |
Output is correct |
7 |
Correct |
1 ms |
2904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
20 ms |
6484 KB |
Output is correct |
3 |
Correct |
15 ms |
5972 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
8 ms |
3744 KB |
Output is correct |
6 |
Correct |
23 ms |
7636 KB |
Output is correct |
7 |
Correct |
1 ms |
2904 KB |
Output is correct |
8 |
Correct |
34 ms |
8612 KB |
Output is correct |
9 |
Correct |
35 ms |
9196 KB |
Output is correct |
10 |
Correct |
51 ms |
11944 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
2 ms |
2648 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
20 ms |
6484 KB |
Output is correct |
3 |
Correct |
15 ms |
5972 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
8 ms |
3744 KB |
Output is correct |
6 |
Correct |
23 ms |
7636 KB |
Output is correct |
7 |
Correct |
1 ms |
2904 KB |
Output is correct |
8 |
Correct |
34 ms |
8612 KB |
Output is correct |
9 |
Correct |
35 ms |
9196 KB |
Output is correct |
10 |
Correct |
51 ms |
11944 KB |
Output is correct |
11 |
Correct |
1 ms |
2652 KB |
Output is correct |
12 |
Correct |
2 ms |
2648 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
63 ms |
12284 KB |
Output is correct |
15 |
Incorrect |
35 ms |
9412 KB |
wrong motion |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2900 KB |
Output is partially correct |
2 |
Correct |
38 ms |
10992 KB |
Output is correct |
3 |
Partially correct |
51 ms |
13500 KB |
Output is partially correct |
4 |
Partially correct |
57 ms |
15172 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2900 KB |
Output is partially correct |
2 |
Correct |
38 ms |
10992 KB |
Output is correct |
3 |
Partially correct |
51 ms |
13500 KB |
Output is partially correct |
4 |
Partially correct |
57 ms |
15172 KB |
Output is partially correct |
5 |
Incorrect |
75 ms |
15112 KB |
wrong motion |
6 |
Halted |
0 ms |
0 KB |
- |