Submission #812691

#TimeUsernameProblemLanguageResultExecution timeMemory
812691HamletPetrosyanBit Shift Registers (IOI21_registers)C++17
33 / 100
1 ms468 KiB
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;

const int M = 100, B = 2000;

// 99 - zero
// 98 - one
// 97 - 2^k - 1

// 1 - cur_min
// 2 - a[i]
// 3 - !a[i]
// 4 - -a[i] or !a[i] + 1
// 5 - cur_min - a[i]

// 6 - rev01(coef_i base)
// 7 - rev01(coef_min base)
// 8 - coef_min
// 9 - coef_i

// 10 - coef_min & cur_min
// 11 - coef_i & a[i]

void construct_instructions(int s, int n, int k, int q) {
	/// init
	vector<bool> stv(B);
	stv[0] = 1;
	append_store(98, stv);										// <------ 1
	for(int i = 1; i < k; i++) stv[i] = 1;
	append_store(97, stv);										// <------ 2
	///
	append_and(1, 97, 0);										// <------ 3
	append_print(1);
	
	for(int i = 1; i < n; i++){
		append_right(2, 0, i * k);									// <------ 1
		append_and(2, 97, 2);										// <------ 2

		/// subtraction
		append_not(3, 2);											// <------ 3
		append_add(4, 3, 98);										// <------ 4
		append_add(5, 1, 4);										// <------ 5
		///

		append_right(7, 5, B - 1);									// <------ 6
		append_xor(6, 7, 98);										// <------ 7

		append_add(8, 97, 6);										// <------ 8
		append_add(9, 97, 7);										// <------ 9

		append_and(10, 1, 8);										// <------ 10
		append_and(11, 2, 9);										// <------ 11

		append_add(1, 10, 11);										// <------ 12
		append_print(1);
	}
	append_move(0, 1);											// <------ 4
}
#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...