# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130271 | khulegub | Mechanical Doll (IOI18_doll) | C++14 | 0 ms | 0 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 "doll.h"
#include <bits/stdc++.h>
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
using namespace std;
typedef pair<int, int> pii;
/**********************/
/* YOU ARE INVITED TO */
/* */
/* SUFFER */
/* */
/* ######## */
/* # JOIN # */
/* ######## */
/* */
/**********************/
void create_circuit(int m, vector<int> a) {
a.pb(0);
int n = a.size();
vector<int> c(m + 1);
vector<int> x, y;
c[0] = a[0];
map<int, unordered_set<int> > garalt;
garalt[0].insert( a[0] );
for (int i = 0; i < n - 1; i++){
garalt[ a[i] ].insert( a[i + 1] );
}
// for (int i = 0; i < n - 1; i++){
// }
int s = 0;
for (auto gang : garalt){
if(gang.yy.size() == 1){
// cout << *gang.yy.begin();
c[gang.xx] = *gang.yy.begin();
}
else{
int gangsz = gang.yy.size();
int gangcnt = 0;
for (auto xaxa : gang.yy){
if (gangcnt == gangsz - 1){
y[s - 1] = xaxa;
break;
}
else if (gangcnt == gangsz - 2){
x.pb(0);
y.pb(0);
c[gang.xx] = -(s + 1);
x[s] = xaxa;
s++;
}
else{
x.pb(0);
y.pb(0);
c[gang.xx] = -(s + 1);
x[s] = xaxa;
y[s] = -(s + 2);
s++;
}
gangcnt++;
}
}
// cout << gang.xx << ' ' << gang.yy.size() << '\n';
}
for (int i = 1; i <= m + 1; i++){
if(c[i] == )
}
//
answer(c, x, y);
}
// int main(){ // DRIVER - CHAN
// create_circuit(9, {1, 3, 2, 1, 3, 4, 2, 1, 3});
// }