#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
#define out(o) cout << o
void create_circuit(int M, vector<int> A) {
int N = A.size();
A.push_back(0);
vector<vector<int>> occ(M + 1);
for (int i = 0; i < N; i++) occ[A[i]].push_back(i);
vector<bool> equal(M + 1, true);
for (int i = 1; i <= M; i++) {
int s = occ[i].size();
for (int j = 1; j < s; j++) if (A[occ[i][j] + 1] != A[occ[i][j - 1] + 1]) equal[i] = false;
}
vector<int> C(M + 1, 0);
vector<int> X;
vector<int> Y;
int S = 0;
C[0] = A[0];
for (int i = 0; i < N; i++) {
if (occ[A[i]].size() == 1 || equal[A[i]]) C[A[i]] = A[i + 1];
else if (occ[A[i]][0] == i) {
if (occ[A[i]].size() == 2) {
S++;
X.push_back(A[i + 1]);
Y.push_back(A[occ[A[i]][1] + 1]);
C[A[i]] = -S;
} else if (occ[A[i]].size() == 3) {
S++;
X.push_back(A[i + 1]);
Y.push_back(-(S + 1));
S++;
X.push_back(A[occ[A[i]][1] + 1]);
Y.push_back(-(S + 2));
S++;
X.push_back(A[occ[A[i]][2] + 1]);
Y.push_back(-S);
C[A[i]] = -S;
} else {
S++;
X.push_back(-(S + 1));
Y.push_back(-(S + 2));
S++;
X.push_back(A[i + 1]);
Y.push_back(A[occ[A[i]][2] + 1]);
S++;
X.push_back(A[occ[A[i]][1] + 1]);
Y.push_back(A[occ[A[i]][3] + 1]);
C[A[i]] = -S;
}
}
}
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
14 ms |
6332 KB |
Output is correct |
3 |
Correct |
14 ms |
5460 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
3932 KB |
Output is correct |
6 |
Correct |
17 ms |
7892 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
14 ms |
6332 KB |
Output is correct |
3 |
Correct |
14 ms |
5460 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
3932 KB |
Output is correct |
6 |
Correct |
17 ms |
7892 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
24 ms |
7356 KB |
Output is correct |
9 |
Correct |
29 ms |
8792 KB |
Output is correct |
10 |
Correct |
39 ms |
11340 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
14 ms |
6332 KB |
Output is correct |
3 |
Correct |
14 ms |
5460 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
3932 KB |
Output is correct |
6 |
Correct |
17 ms |
7892 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
24 ms |
7356 KB |
Output is correct |
9 |
Correct |
29 ms |
8792 KB |
Output is correct |
10 |
Correct |
39 ms |
11340 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
43 ms |
11084 KB |
wrong serial number |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |