# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110145 | StefanSebez | Mechanical Doll (IOI18_doll) | C++14 | 48 ms | 10384 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"
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
const int lg=18;
void create_circuit(int M, std::vector<int> A){
int n=A.size();A.pb(0);
vector<int>C(M+1);C[0]=A[0];
vector<int>X,Y;
if(M==1){
C[1]=-1;
int x=n-1;
for(int i=1;i<=lg;i++){
if((x>>(lg-i))&1==1){
X.pb(1);
}
else X.pb(-1);
Y.pb(-i-1);
}
Y.back()=0;
}
else{
/*X.resize(M),Y.resize(M);
for(int i=1;i<=M;i++)C[i]=-i;*/
vector<int>vals[M+50];
for(int i=0;i<n;i++) vals[A[i]].pb(A[i+1]);
for(int i=1;i<=M;i++){
if(vals[i].size()==1) C[i]=vals[i][0];
if(vals[i].size()<=1) continue;
int nc=X.size()+1;
C[i]=-nc;
if(vals[i].size()==2){
X.pb(vals[i][0]);
Y.pb(vals[i][1]);
}
else if(vals[i].size()==3){
X.pb(-(nc+1));
Y.pb(-(nc+2));
X.pb(vals[i][0]);
Y.pb(-nc);
X.pb(vals[i][1]);
Y.pb(vals[i][2]);
}
else{
X.pb(-(nc+1));
Y.pb(-(nc+2));
X.pb(vals[i][0]);
Y.pb(vals[i][2]);
X.pb(vals[i][1]);
Y.pb(vals[i][3]);
}
}
}
//for(auto i:C) printf("%i ",i);printf("\n");
//for(int i=0;i<X.size();i++) printf("{%i %i}\n",X[i],Y[i]);
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... |