#include "doll.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int n = 2e5 + 123;
int used[n];
vector <int> pos[n];
void create_circuit(int M, std::vector<int> A) {
int N = A.size(), cnt = 0;
A.pb(0);
for (int i = 0; i < N; i++)
pos[A[i]].pb(i);
std::vector<int> C(M + 1), X(2 * N), Y(2 * N);
C[0] = A[0];
for (int i = 0; i < N; i++) {
if (used[A[i]]) continue;
used[A[i]] = 1;
if (SZ(pos[A[i]]) == 1) {
C[A[i]] = A[i + 1];
} else {
C[A[i]] = -(++cnt);
for (int j = 1; j < SZ(pos[A[i]]); j++) {
int x = pos[A[i]][j];
if (j == SZ(pos[A[i]]) - 1)
X[cnt - 1] = A[i + 1];
else {
X[cnt - 1] = -(cnt + 1);
}
Y[cnt - 1] = A[x + 1];
//if (A[i] == 2) {
//cout << "x = " << x << '\n';
//cout << "A[" << x + 1 << "] = " << A[x + 1] << '\n';
//cout << "X Y " << X[cnt - 1] << ' ' << Y[cnt - 1] << '\n';
//}
if (j < SZ(pos[A[i]]) - 1)
cnt++;
}
}
}
X.resize(cnt), Y.resize(cnt);
//for (int i = 0; i <= M; i++) cout << C[i] << ' ';
//cout << '\n';
//for (int i = 0; i < cnt; i++) cout << X[i] << ' ' << Y[i] << '\n';
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
45 ms |
10128 KB |
Output is correct |
3 |
Correct |
35 ms |
9612 KB |
Output is correct |
4 |
Correct |
6 ms |
4940 KB |
Output is correct |
5 |
Correct |
23 ms |
6220 KB |
Output is correct |
6 |
Correct |
58 ms |
12028 KB |
Output is correct |
7 |
Correct |
5 ms |
4940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
45 ms |
10128 KB |
Output is correct |
3 |
Correct |
35 ms |
9612 KB |
Output is correct |
4 |
Correct |
6 ms |
4940 KB |
Output is correct |
5 |
Correct |
23 ms |
6220 KB |
Output is correct |
6 |
Correct |
58 ms |
12028 KB |
Output is correct |
7 |
Correct |
5 ms |
4940 KB |
Output is correct |
8 |
Correct |
67 ms |
12168 KB |
Output is correct |
9 |
Correct |
97 ms |
13032 KB |
Output is correct |
10 |
Correct |
143 ms |
15936 KB |
Output is correct |
11 |
Correct |
4 ms |
4972 KB |
Output is correct |
12 |
Correct |
4 ms |
4940 KB |
Output is correct |
13 |
Correct |
5 ms |
4940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
45 ms |
10128 KB |
Output is correct |
3 |
Correct |
35 ms |
9612 KB |
Output is correct |
4 |
Correct |
6 ms |
4940 KB |
Output is correct |
5 |
Correct |
23 ms |
6220 KB |
Output is correct |
6 |
Correct |
58 ms |
12028 KB |
Output is correct |
7 |
Correct |
5 ms |
4940 KB |
Output is correct |
8 |
Correct |
67 ms |
12168 KB |
Output is correct |
9 |
Correct |
97 ms |
13032 KB |
Output is correct |
10 |
Correct |
143 ms |
15936 KB |
Output is correct |
11 |
Correct |
4 ms |
4972 KB |
Output is correct |
12 |
Correct |
4 ms |
4940 KB |
Output is correct |
13 |
Correct |
5 ms |
4940 KB |
Output is correct |
14 |
Incorrect |
118 ms |
14908 KB |
state 'Y' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
4940 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4940 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4940 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |