제출 #453633

#제출 시각아이디문제언어결과실행 시간메모리
453633mjhmjh1104Bit Shift Registers (IOI21_registers)C++17
10 / 100
1 ms332 KiB
#include "registers.h"

int n, k;

void compare(int x, int y) {
	append_not(n, y);
	append_or(n + 1, x, n);
	append_and(n + 2, x, n);
	for (int i = 0; i < k; i++) {
		append_and(n + 3, n + 3, n + 1);
		append_or(n + 3, n + 3, n + 2);
		append_right(n + 1, n + 1, 1);
		append_right(n + 2, n + 2, 1);
	}
	append_left(n + 3, n + 3, 1999);
	append_right(n + 3, n + 3, 1999);
	for (int i = 1; i < k; i++) {
		append_left(n + 4, n + 3, i);
		append_or(n + 3, n + 3, n + 4);
	}
	append_and(n + 5, x, n + 3);
	append_xor(y, y, n + 5);
	append_and(n + 5, y, n + 3);
	append_xor(x, x, n + 5);
	append_and(n + 5, x, n + 3);
	append_xor(y, y, n + 5);
}

void construct_instructions(int s, int n, int k, int q) {
	::n = n, ::k = k;
	for (int i = 1; i < n; i++) {
		if (2000 - k * (i + 1) > 0) append_left(i, 0, 2000 - k * (i + 1));
		append_right(i, i, 2000 - k);
	}
	append_left(0, 0, 2000 - k);
	append_right(0, 0, 2000 - k);
	for (int i = 1; i < n; i++) compare(0, i);
	for (int i = 1; i < n; i++) {
		append_left(i, i, k * i);
		append_or(0, 0, i);
	}
}
#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...