Submission #818586

# Submission time Handle Problem Language Result Execution time Memory
818586 2023-08-10T05:37:12 Z LittleCube Bit Shift Registers (IOI21_registers) C++17
0 / 100
0 ms 340 KB
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;

const int M = 100, B = 2000;

void keep_prefix(int x, int l)
{
	append_left(x, x, B - l);
	append_right(x, x, B - l);
}

void or_numbers(int n, int k, int t, int x)
{
	/*
		bit or n k-bit numbers stored at first k bits
		x: array
		10, 11: working space
		12: empty filter
		t: output
	*/
	append_move(10, x);
	while (n > 1)
	{
		int m = (n + 1) / 2;
		append_right(11, 10, m * k);
		append_or(10, 11, 10);
		n = m;
	}
	keep_prefix(10, k);
	append_move(t, 10);
}

void dupe_numbers(int n, int k, int x)
{
	/*
		duplicate a k-bit number n times
		x: array, output
		20, 21: working space
	*/
	int m = 1;
	for (; m + m < n; m += m)
	{
		append_left(21, x, m * k);
		append_or(x, 21, x);
	}
	append_left(x, x, (n - m) * k);
}

void construct_instructions(int s, int n, int k, int q)
{
	/*
		filter msb
		0: array
		1: every k bits only i-th has value
		2: filter
		3: filter helper
		4: empty checker
		5: stupid
		6: full
		-> 0: filtered array
	*/
	vector<bool> stupid(B, 0), full(B, 1), one(B, 0);
	for (int i = 0; i < n * k; i++)
		stupid[i] = 1;
	one[0] = 1;
	append_store(5, stupid);
	append_store(6, full);
	append_store(7, one);
	append_xor(0, 0, 5);
	for (int i = k - 1; i >= 0; i--)
	{
		vector<bool> filter(B, 0);
		for (int j = i; j < n * k; j += k)
			filter[j] = 1;
		append_store(1, filter);
		append_and(2, 0, 1);
		// if none of them has the bit, 4 stores all 1 and becomes all zero when added 1, 
		// thus not again and set the filter to all 1
		append_right(2, 2, i);
		append_not(4, 2);
		append_add(4, 4, 7);
		append_not(4, 4);
		append_right(4, 4, B - 1);
		append_add(4, 4, 6);
		dupe_numbers(k, 1, 2);
		append_or(2, 4, 2);
		append_and(0, 2, 0);
	}
	or_numbers(n, k, 0, 0);
	append_xor(0, 0, 5);
	keep_prefix(0, k);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Incorrect min value
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Incorrect min value
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Incorrect sorting
2 Halted 0 ms 0 KB -