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"
using namespace std;
#define sz(x) (int)x.size()
void create_circuit(int M, vector<int> A) {
vector<int> C(M+1), X, Y;
vector<vector<int>> cnt(M);
A.push_back(0);
cnt[0].push_back(A[0]);
for(int i=0; i<sz(A)-1; i++) cnt[A[i]].push_back(A[i+1]);
C[0] = A[0];
for(int i=1; i<M+1; i++) {
if(cnt[i].empty()) C[i] = i;
}
vector<bool> ok(M+1, false);
int current_s = -1;
for(int i=0; i<sz(A)-1; i++) {
if(ok[A[i]]) continue;
if(sz(cnt[A[i]]) == 1) C[A[i]] = cnt[A[i]][0];
else {
C[A[i]] = current_s;
X.push_back(cnt[A[i]][0]);
Y.push_back(cnt[A[i]][1]);
current_s--;
}
ok[A[i]] = true;
}
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... |