Submission #818188

# Submission time Handle Problem Language Result Execution time Memory
818188 2023-08-10T03:31:53 Z LittleCube Bit Shift Registers (IOI21_registers) C++17
22 / 100
1 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);
		keep_prefix(10, m * k);
		n = m;
	}
	append_move(t, 10);
}

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

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
		-> 0: filtered array
	*/
	vector<bool> stupid(B, 0);
	for (int i = 0; i < n * k; i++)
		stupid[i] = 1;
	append_store(5, stupid);
	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, set the filter to all 1
		or_numbers(n * k, 1, 4, 2);
		append_print(4);
		append_not(4, 4);
		keep_prefix(4, 1);
		append_print(4);
		append_left(2, 2, k - 1 - i);
		dupe_numbers(n * k, 1, 4, 4);
		append_print(4);
		for (int j = 1; j < k; j++)
		{
			append_right(3, 2, 1);
			append_or(2, 2, 3);
		}
		append_print(2);
		append_or(2, 4, 2);
		append_and(0, 2, 0);
		append_print(0);
	}
	or_numbers(n, k, 0, 0);
	append_xor(0, 0, 5);
	keep_prefix(0, k);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# 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 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 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 1 ms 340 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Incorrect sorting
2 Halted 0 ms 0 KB -