Submission #75454

#TimeUsernameProblemLanguageResultExecution timeMemory
75454sevenkplusMechanical Doll (IOI18_doll)C++11
47 / 100
119 ms9212 KiB
#include "doll.h"

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pct __builtin_popcount

void create_circuit(int m, vector<int> a) {
	int n = a.size();
	vector<int> sc(m + 1, -1);
	sc[0] = a[0];
	
	vector<int> b;
	for (int i = 1; i < n; i ++) b.pb(a[i]);
	b.pb(0);

	int p = 1;
	while (p < n) p *= 2;
	vector<int> sx(p-1);
	vector<int> sy(p-1);
	vector<bool> t(p-1, 0);
	for (int i = 0; i < p/2-1; i ++) {
		sx[i] = -(i*2+1 +1);
		sy[i] = -(i*2+2 +1);
	}
	for (int i = 0; i < p; i ++) {
		int x = 0;
		while (x < p-1) {
			if (t[x] == 1) {
				t[x] = 0;
				x = x*2+2;
			} else {
				t[x] = 1;
				x = x*2+1;
			}
		}
		int ne = -1;
		if (i >= p-n) ne = b[i-(p-n)];
		if (x%2) sx[(x-1)/2] = ne;
		else sy[(x-1)/2] = ne;
	}
	
	answer(sc, sx, sy);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...