제출 #439301

#제출 시각아이디문제언어결과실행 시간메모리
439301rainboy레지스터 (IOI21_registers)C++17
46 / 100
1 ms620 KiB
#include "registers.h"
#include <vector>

using namespace std;

typedef vector<bool> vb;

const int N = 128, L = 7, B = 2000;

void construct_instructions(int s, int n, int k, int q) {
	int h, i, u, v, l;

	if (s == 0) {
		vb aa(B, 0), bit(B, 0);

		for (i = n; i < N; i++)
			aa[i * k + k - 1] = 1;
		bit[k - 1] = 1;
		append_store(1, aa), append_store(6, bit);
		for (h = k - 1; h >= 0; h--) {
			append_or(2, 0, 1), append_right(3, 2, k), append_and(3, 3, 2);
			if (n > 2)
				for (l = 1; l < L; l++)
					append_right(4, 3, k << l), append_and(3, 3, 4);
			append_and(3, 3, 6);
			append_or(5, 5, 3);
			if (h > 0) {
				for (l = 0; l < L; l++)
					if (l == 0 || n > 2)
						append_left(4, 3, k << l), append_or(3, 3, 4);
				append_not(3, 3), append_and(2, 2, 3), append_or(1, 1, 2);
				append_right(1, 1, 1), append_right(6, 6, 1);
			}
		}
		append_move(0, 5);
	} else {
		vb one(B, 0), uu(B, 0);
		int h;

		one[0] = 1;
		for (h = 0; h < k; h++)
			uu[h] = 1;
		append_store(98, one), append_store(97, uu);
		for (u = 0; u < n; u++) {
			for (v = u + 1; v < n; v++) {
				append_right(1, 0, (v - u) * k);
				append_xor(2, 0, 1);
				append_not(1, 1), append_and(3, 0, 1), append_or(4, 0, 1), append_not(1, 1);
				append_move(5, 99);
				for (h = 0; h < k; h++) {
					append_or(5, 5, 3), append_and(5, 5, 4);
					if (h + 1 < k)
						append_left(5, 5, 1);
					else
						append_right(5, 5, u * k + (k - 1));
				}
				append_and(5, 5, 98), append_not(5, 5), append_add(5, 5, 98), append_and(5, 5, 2);
				append_and(5, 5, 97), append_left(6, 5, (v - u) * k), append_or(5, 5, 6);
				append_xor(0, 0, 5);
			}
			append_left(97, 97, k);
		}
	}
}
#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...