This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |