#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;
using int64 = long long;
using ld = long double;
constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;
vector<int> C;
vector<int> X;
vector<int> Y;
void connect(const int x, const vector<int> &next) {
const int neighbours = (int) next.size();
if (neighbours == 0) {
C[x] = x;
} else if (neighbours == 1) {
C[x] = next[0];
} else if (neighbours == 2) {
X.push_back(next[0]);
Y.push_back(next[1]);
C[x] = -1 * (int) (X.size());
} else if (neighbours == 3) {
const int s1 = -1 * ((int) X.size() + 1);
const int s2 = s1 - 1;
const int s3 = s1 - 2;
//C[x] connections
C[x] = s1;
//s1 connections
X.push_back(s2);
Y.push_back(s3);
//s2 connections
X.push_back(next[0]);
Y.push_back(s1);
//s3 connections
X.push_back(next[1]);
Y.push_back(next[2]);
} else {
const int s1 = -1 * (int) X.size() + 1;
const int s2 = s1 - 1;
const int s3 = s1 - 2;
//C[x] connections
C[x] = s1;
//s1 connections
X.push_back(s2);
Y.push_back(s3);
//s2 connections
X.push_back(next[0]);
Y.push_back(next[2]);
//s3 connections
X.push_back(next[1]);
Y.push_back(next[3]);
}
}
void create_circuit(int m, std::vector<int> A) {
const int n = A.size();
C.resize(m + 1);
vector<vector<int>> next(m + 1);
next[0].push_back(A[0]);
for (int i = 0; i < n - 1; i++) {
next[A[i]].push_back(A[i + 1]);
}
next[A[n - 1]].push_back(0);
for (int x = 0; x <= m; x++) {
connect(x, next[x]);
}
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
31 ms |
6288 KB |
Output is correct |
3 |
Correct |
19 ms |
5180 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
14 ms |
3796 KB |
Output is correct |
6 |
Correct |
28 ms |
7600 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
31 ms |
6288 KB |
Output is correct |
3 |
Correct |
19 ms |
5180 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
14 ms |
3796 KB |
Output is correct |
6 |
Correct |
28 ms |
7600 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
41 ms |
7216 KB |
Output is correct |
9 |
Correct |
48 ms |
8584 KB |
Output is correct |
10 |
Correct |
82 ms |
11048 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
31 ms |
6288 KB |
Output is correct |
3 |
Correct |
19 ms |
5180 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
14 ms |
3796 KB |
Output is correct |
6 |
Correct |
28 ms |
7600 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
41 ms |
7216 KB |
Output is correct |
9 |
Correct |
48 ms |
8584 KB |
Output is correct |
10 |
Correct |
82 ms |
11048 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
79 ms |
10976 KB |
Output is correct |
15 |
Incorrect |
41 ms |
5800 KB |
wrong motion |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |