답안 #774946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
774946 2023-07-06T06:10:25 Z SanguineChameleon 레지스터 (IOI21_registers) C++17
47 / 100
1 ms 212 KB
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;

namespace sub0 {
	const int PLUS_ONE = 99;
	const int PLUS_ONE_LSB = 98;
	const int ONLY_MSB = 97;
	const int OFF_MSB = 96;
	const int MSB_ZERO = 95;
	const int MSB_ONE = 94;
	const int ALL_ONES = 93;
	const int ALL_ZEROES = 92;
	vector<bool> BITS(2000);

	void solve(int N, int K) {
		int pw = 1;
		while (pw < N) {
			pw <<= 1;
		}
		BITS[0] = 1;
		append_store(PLUS_ONE, BITS);
		BITS[0] = 0;
		for (int i = N * K; i < pw * K; i++) {
			BITS[i] = 1;
		}
		append_store(1, BITS);
		append_or(0, 0, 1);
		for (int i = N * K; i < pw * K; i++) {
			BITS[i] = 0;
		}
		N = pw;
		for (int i = 0; i < N * K; i++) {
			BITS[i] = 1;
		}
		append_store(ALL_ONES, BITS);
		append_not(ALL_ZEROES, ALL_ONES);
		for (int i = 0; i < N * K; i++) {
			BITS[i] = 0;
		}
		for (int i = 0; i < N; i++) {
			BITS[(i + 1) * K - 1] = 1;
		}
		append_store(ONLY_MSB, BITS);
		for (int i = 0; i < N; i++) {
			BITS[(i + 1) * K - 1] = 0;
		}
		for (int i = 0; i < N; i++) {
			BITS[i * K] = 1;
		}
		append_store(PLUS_ONE_LSB, BITS);
		append_not(OFF_MSB, ONLY_MSB);
		append_not(1, 0);
		append_and(2, 1, ONLY_MSB);
		append_add(MSB_ZERO, 2, ALL_ONES);
		append_and(MSB_ZERO, MSB_ZERO, ALL_ZEROES);
		append_right(MSB_ONE, MSB_ZERO, N * K);
		append_not(MSB_ONE, MSB_ONE);
		append_add(MSB_ZERO, MSB_ZERO, MSB_ONE);
		append_add(MSB_ZERO, MSB_ZERO, PLUS_ONE);
		append_not(MSB_ONE, MSB_ZERO);
		append_right(3, 2, K - 1);
		append_not(3, 3);
		append_add(2, 2, 3);
		append_add(2, 2, PLUS_ONE);
		append_and(1, 1, 2);
		append_not(1, 1);
		append_not(ONLY_MSB, ONLY_MSB);
		append_and(1, 1, ONLY_MSB);
		append_not(ONLY_MSB, ONLY_MSB);
		append_and(2, 0, ONLY_MSB);
		append_right(3, 2, K - 1);
		append_not(3, 3);
		append_add(2, 2, 3);
		append_add(2, 2, PLUS_ONE);
		append_and(2, 0, 2);
		append_and(1, 1, MSB_ZERO);
		append_and(2, 2, MSB_ONE);
		append_add(0, 1, 2);
		while (N > 1) {
			append_right(1, 0, (N / 2) * K);
			append_not(2, 1);
			append_and(2, 2, OFF_MSB);
			append_add(2, 0, 2);
			append_add(2, 2, PLUS_ONE_LSB);
			append_and(2, 2, ONLY_MSB);
			append_right(3, 2, K - 1);
			append_not(3, 3);
			append_add(2, 2, 3);
			append_add(2, 2, PLUS_ONE);
			append_not(3, 2);
			append_and(0, 0, 3);
			append_and(1, 1, 2);
			append_add(0, 0, 1);
			N /= 2;
		}
		append_and(ONLY_MSB, ONLY_MSB, MSB_ONE);
		append_add(0, 0, ONLY_MSB);
	}
}

namespace sub1 {
	void solve(int n, int k) {


	}
}

void construct_instructions(int s, int n, int k, int q) {
	if (s == 0) {
		sub0::solve(n, k);
	}
	else {
		sub1::solve(n, k);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -