# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94983 | someone_aa | Mechanical Doll (IOI18_doll) | C++17 | 123 ms | 11748 KiB |
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 <bits/stdc++.h>
#include "doll.h"
#define pb push_back
#define mp make_pair
using namespace std;
const int maxm = 100100;
vector<int> after[maxm];
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
std::vector<int> C(M + 1, 0);
C[0] = A[0];
for(int i=1;i<A.size();i++) {
after[A[i-1]].pb(A[i]);
}
after[A.back()].pb(0);
vector<int> X, Y;
int br = 1;
for(int i=1;i<=M;i++) {
//cout<<i<<": "<<after[i].size()<<"\n";
if(after[i].size() == 0) continue;
else if(after[i].size() == 1) {
C[i] = after[i][0];
}
else if(after[i].size() == 2){
C[i] = -br;
X.pb(after[i][0]);
Y.pb(after[i][1]);
br++;
}
else if(after[i].size() == 3) {
C[i] = -br;
int lbr = br + 1;
int rbr = br + 2;
X.pb(-lbr);
Y.pb(-rbr);
//cout<<i<<": "<<(-lbr)<<" and "<<(-rbr)<<"\n";
X.pb(after[i][0]);
Y.pb(-br);
//cout<<after[i][0]<<" "<<i<<"\n";
X.pb(after[i][1]);
Y.pb(after[i][2]);
br += 3;
}
else {
C[i] = -br;
int lbr = br + 1;
int rbr = br + 2;
X.pb(-lbr);
Y.pb(-rbr);
X.pb(after[i][0]);
Y.pb(after[i][2]);
X.pb(after[i][1]);
Y.pb(after[i][3]);
br += 3;
}
}
/*for (int k = 0; k < N; ++k) {
X[k] = Y[k] = A[k];
}*/
answer(C, X, Y);
}
Compilation message (stderr)
# | 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... |