Submission #444826

# Submission time Handle Problem Language Result Execution time Memory
444826 2021-07-15T14:07:12 Z Xellos Bit Shift Registers (IOI21_registers) C++17
22 / 100
1 ms 332 KB
#include "registers.h"
#include <vector>
using namespace std;

constexpr static int B = 2000;

void construct_instructions(int s, int n, int k, int q) {
	// pad with 1
	vector<bool> ones_pad(B, false);
	for(int i = n*k; i < 128*k; i++) ones_pad[i] = true;
	append_store(1, ones_pad);
	append_or(2, 0, 1);
	int offset = 2;
	vector<bool> first_bits_0[11];
	for(int i = 1; i <= k; i++) {
		first_bits_0[i].resize(B, false);
		for(int j = 0; j < 128*k; j++) first_bits_0[i][j] = (j%k >= i);
	}
	vector<bool> last_bits_0[11];
	for(int i = 1; i <= k; i++) {
		last_bits_0[i].resize(B, false);
		for(int j = 0; j < 128*k; j++) last_bits_0[i][j] = (j%k < k-i);
	}
	append_store(0, last_bits_0[1]);
	append_store(1, first_bits_0[1]);
	for(int j = 0; j < 7; j++) {
		// offset holds "input"
		// split to 2 parts
		append_right(offset+1, offset, k<<(6-j));
		append_xor(offset+2, offset, offset+1); // X
		// most significant bit of xor
		for(int i = 0; i < k; i++) {
			append_right(offset+3+3*i, offset+2+3*i, 1);
			append_and(offset+4+3*i, 0, offset+3+3*i);
			append_or(offset+2+3*(i+1), offset+4+3*i, offset+2+3*i);
		}
		append_right(offset+3, offset+2+3*k, 1); // X = X ^ (X >> 1)
		append_and(offset+4, 0, offset+3);
		append_xor(offset+2, offset+4, offset+2+3*k); // X = X ^ (X >> 1)
		// concat X+X
		vector<bool> v(B, false);
		for(int i = 0; i < (k<<(6-j)); i++) v[i] = true;
		append_store(offset+3, v);
		append_and(offset+4, offset+2, offset+3);
		append_left(offset+3, offset+4, k<<(6-j));
		append_or(offset+2, offset+3, offset+4); // X+X
		append_and(offset+6, offset, offset+2); // B
		// expand k-bit chunks of B
		for(int i = 0; i < k; i++) {
			append_left(offset+7+3*i, offset+6+3*i, 1);
			append_and(offset+8+3*i, 1, offset+7+3*i);
			append_or(offset+6+3*(i+1), offset+8+3*i, offset+6+3*i);
		}
		for(int i = 0; i < k; i++) {
			append_right(offset+5+3*(k-i), offset+6+3*(k-i), 1);
			append_and(offset+4+3*(k-i), 0, offset+5+3*(k-i));
			append_or(offset+6+3*(k-i-1), offset+4+3*(k-i), offset+6+3*(k-i));
		}
		append_not(offset+7, offset+6);
		append_right(offset+8, offset+7, k<<(6-j));
		append_not(offset+9, offset+8);
		append_and(offset+10, offset, offset+9);
		append_and(offset+11, offset+1, offset+8);
		append_or(offset+12, offset+11, offset+10);
		offset += 12;
		if(offset > 50) {
			append_move(2, offset);
			offset = 2;
		}
	}
	append_move(0, offset);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 280 KB Wrong answer detected in grader
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 280 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect sorting
2 Halted 0 ms 0 KB -