제출 #1242988

#제출 시각아이디문제언어결과실행 시간메모리
1242988trimkus레지스터 (IOI21_registers)C++20
21 / 100
0 ms328 KiB
#include "registers.h"

void construct_instructions(int s, int n, int k, int q) {
	// append_move(1, 0);
	// append_right(1, 1, 1);
	// append_and(0, 0, 1);
	// for (int i = 0; i < n; ++i) {
	// 	append_move(i + 1, 0);
	// 	// append_print(i + 1);
	// }
	for (int i = 1; i <= 1; ++i) {

		// append_left(i, i, (i - 1) * k);
		append_right(i, 0, i * k);
		append_left(i, i, i * k);
	}
	append_xor(2, 0, 1);
	append_right(1, 1, 1 * k);
	// for (int i = 0; i < n; ++i) {
	// 	append_print(i + 1);
	// }
	int one = n + 3, one1 = n + 4;
	append_not(one, one);
	append_not(one1, one1);
	append_left(one1, one1, 1);
	append_xor(one, one1, one);
	// append_print(one);
	int dec = n + 5;
	// a1 - a2
	append_not(dec, 2);
	append_add(dec, dec, one);
	append_add(dec, dec, 1);
	// append_print(dec);
	//
	int mult = n + 6;
	// if mult = 1 => a1 > a2 else a2 >= a1
	append_right(mult, dec, k * (n - 1));
	append_and(mult, mult, one);
	// append_print(mult);
	//
	// (a1 & ~(-mult)) | (a2 & -mult)
	// nk1 = ~(-mult)
	// nk2 = -mult
	int res1 = n + 7, res2 = n + 10;
	int nk1 = n + 8, nk2 = n + 9;
	// -a = (~a + 1)
	append_not(nk2, mult);
	append_add(nk2, nk2, one);
	// ~(-a) = ~(~a + 1)
	append_not(nk1, nk2);

	append_and(res1, 1, nk2);
	append_and(res2, 2, nk1);
	int res = n + 11;
	append_or(res, res1, res2);
	// append_right(mult, dec, k * (n - 1));
	append_print(res);
	append_move(0, res);
}
#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...