# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289929 | dandrozavr | Mechanical Doll (IOI18_doll) | C++14 | 1104 ms | 131736 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 <vector>
#include <iostream>
#define pb push_back
#define F first
#define S second
#define _ <<" "<<
#define pii pair < int , int >
using namespace std;
void create_circuit (int m, vector < int > a) {
int n = a.size();
a.pb(0);
vector < int > c;
vector < int > g[n + 1];
for (int i = 1; i <= n; ++i){
g[a[i - 1]].pb(a[i]);
}
g[0].pb(a[0]);
int now = 1;
vector < pii > swit;
for (int i = 0; i <= n; ++i){
int sz = g[i].size();
cout << i _ sz << endl;
if (!sz){
c.pb(0);
continue;
}
if (sz == 1){
c.pb(g[i][0]);
} else {
vector < int > all;
for (int j = 0; j < sz; ++j){
all.pb(g[i][j]);
}
while(all.size() > 1){
vector < int > nall;
for (int i = 0; i < all.size(); i += 2){
int Pr = swit.size() + 1;
swit.pb({all[i], all[i + 1]});
nall.pb(-Pr);
}
if (all.size() % 2){
nall.pb(all.back());
}
swap(nall, all);
}
c.pb(all[0]);
}
}
// for (int i : c) cout << i << " ";
// cout << endl;
vector < int > X, Y;
for (int i = 0; i < swit.size(); ++i){
X.pb(swit[i].F), Y.pb(swit[i].S);
// cout << X.back() _ Y.back() << endl;
}
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... |