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>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(), order_of_key()
typedef long long ll;
typedef long double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<dd, dd> pdd;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<dd> vdd;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vdd> vvdd;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
typedef vector<vpdd> vvpdd;
typedef vector<bool> vb;
const int inf = 1 << 30;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ffor(i, a, b) for(ll i = a; i < b; i++)
#define forin(x, a) for (auto &x: a)
#define all(x) x.begin(), x.end()
#ifdef TEST
#define dbg(x) cout << #x << ": " << x << '\n';
#define dbgc(x) cout << #x << ":"; forin(a, x) { cout << " " << a; } cout << endl;
#define tassert(x) assert(x);
#else
#define dbg(x)
#define dbgc(x)
#define tassert(x)
#endif
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
map<int, int> counts;
int max_count = 0;
forin(x, A) {
counts[x]++;
max_count = max(max_count, counts[x]);
}
vii C(M + 1);
if (max_count == 1) {
rep(i, N - 1) {
C[A[i]] = A[i + 1];
}
C[0] = A[0];
C[A[N - 1]] = 0;
answer(C, vii(), vii());
} else if (max_count == 2) {
int curr_trigger = -1;
vii X, Y;
C[0] = A[0];
A.emplace_back(0);
rep(i, N) {
if (counts[A[i]] == 2) {
if (C[A[i]] == 0) {
C[A[i]] = curr_trigger;
curr_trigger--;
X.emplace_back(A[i + 1]);
Y.emplace_back(0);
} else {
Y[-1 - C[A[i]]] = A[i + 1];
}
} else {
C[A[i]] = A[i + 1];
}
}
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... |