#include "doll.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <functional>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <cassert>
#include <random>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define length(a) (int)a.size()
using namespace std;
template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
while (begin != end) {
out << (*begin) << ' ';
begin++;
}
out << endl;
}
template<class T> void output(const T &x, ostream &out = cerr) {
output(x.begin(), x.end(), out);
}
template<class T> int chkmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template<class T> int chkmax(T &a, const T &b) {
if (b > a) {
a = b;
return 1;
}
return 0;
}
void fast_io() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
vector<int> C, X, Y;
int transform(int id) {
return -(id + 1);
}
int new_vertex() {
X.push_back(0);
Y.push_back(0);
return length(X) - 1;
}
int build_binary(vector<int> a) {
if (a.size() == 1) {
if (a[0] >= 1) {
C[a[0]] = -1;
}
return a[0];
}
vector<int> a1, a2;
int v = new_vertex();
for (int i = 0; i < length(a); ++i) {
if ((i % 2) == 0) {
a1.push_back(a[i]);
} else {
a2.push_back(a[i]);
}
}
int v1 = build_binary(a1);
int v2 = build_binary(a2);
X[v] = v1;
Y[v] = v2;
return transform(v);
}
int n;
vector<int> a;
void build() {
int rv = 0;
while ((1 << rv) - 1 < n) {
rv++;
new_vertex();
}
for (int i = 0; i < rv - 1; ++i) {
Y[i] = transform(i + 1);
}
Y[rv - 1] = 0;
vector<int> order;
for (int i = 1; i < (1 << rv); ++i) {
int cnt = 0;
int x = i;
while ((x & 1) == 0) {
cnt++;
x >>= 1;
}
if ((n >> (rv - 1 - cnt)) & 1) {
order.push_back(cnt);
}
}
assert(length(order) == n);
vector<vector<int> > as(rv);
for (int i = 0; i < n; ++i) {
as[order[i]].push_back(a[i]);
}
for (int i = 0; i < rv; ++i) {
if (as[i].empty()) {
X[i] = -1;
} else {
X[i] = build_binary(as[i]);
}
}
}
void create_circuit(int M, vector<int> _a) {
a = _a;
C.resize(M + 1);
n = a.size();
build();
C[0] = -1;
// output(all(X));
// output(all(Y));
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |