Submission #130495

# Submission time Handle Problem Language Result Execution time Memory
130495 2019-07-15T11:05:10 Z khulegub Mechanical Doll (IOI18_doll) C++14
0 / 100
1 ms 204 KB
#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 #      */
/*      ########      */
/*                    */
/**********************/
vector<bool> tree;
int treesz;
pii trial(int node){
	if (node*2 + 1 > treesz - 1){ //last node??
		tree[node] = tree[node] ^ 1;
		return mp(tree[node] ^ 1, node);
	}
	if (tree[node]){ // baruun child
		tree[node] = tree[node] ^ 1;
		return trial(node*2 + 2);
	}
	else{
		tree[node] = tree[node] ^ 1;
		return trial(node*2 + 1);
	}
}
void create_circuit(int m, vector<int> a) {
	a.pb(0);
	int n = a.size();
	vector<int> c(m + 1);
	// = 1 << (int) ceil( log((double) n)/log(2.0) );
	vector<int> x, y;

	treesz = (n - 1) + ((int) ceil( log((double) n - 1)/log(2.0) ));
  	if(treesz == 0) treesz++;
	x.resize(treesz);
	y.resize(treesz);
	tree.resize(treesz);
	// cout << N << '\n';
	c[0] = -1; //connect it to first switch
	for (int i = 0; i < treesz; i++){
		pii tmp = trial(0);
		if (i < n - 1){
			c[a[i]] = -1;
			// cout << tmp.xx << "&" << tmp.yy << "&" << a[i] << '\n';
			if (tmp.xx == 0){
				x[tmp.yy] = a[i];
			}
			else{
				y[tmp.yy] = a[i];
			}
		}
		else if (i == treesz - 1){
			if (tmp.xx == 0){
				x[tmp.yy] = 0;
			}
			else{
				y[tmp.yy] = 0;
			}
		}
		else{
			if (tmp.xx == 0){
				x[tmp.yy] = -1;
			}
			else{
				y[tmp.yy] = -1;
			} 
		}
		
	}
	for (int i = 0; i * 2 + 1 <=treesz - 1; i++){
		x[i] = -(i*2 + 1 + 1);
		y[i] = -(i*2 + 2 + 1);
	}
	// switch with N different outputs
	// for (int X : y){
	// 	cout << X << ' ';
	// }
	answer(c, x, y);
}

// int main(){ // DRIVER - CHAN
// 	create_circuit(4, {1, 2, 1, 3});
// }
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong serial number
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -