Submission #1201668

#TimeUsernameProblemLanguageResultExecution timeMemory
1201668HappyCapybara레지스터 (IOI21_registers)C++17
46 / 100
1 ms748 KiB
#include "registers.h"
#include<bits/stdc++.h>
using namespace std;

int x = 4;

void comp(int a, int b, bool c=false){
	append_xor(90, a, b);
	for (int i=0; i<x; i++){
		append_right(91, 90, 1<<i);
		append_or(90, 90, 91);
	}
	append_add(90, 90, 97);
	append_right(90, 90, 1);
	append_and(91, a, 90);
	for (int i=0; i<x; i++){
		append_right(92, 91, 1<<i);
		append_or(91, 91, 92);
		append_left(92, 91, 1<<i);
		append_or(91, 91, 92);
	}
	append_not(92, 91);
	if (c){
		append_and(93, a, 92);
		append_and(94, b, 91);
		append_add(0, 93, 94);
		return;
	}
	append_and(93, a, 91);
	append_and(94, b, 92);
	append_add(95, 93, 94);
	append_and(93, a, 92);
	append_and(94, b, 91);
	append_move(a, 95);
	append_add(b, 93, 94);
}

void construct_instructions(int s, int n, int k, int q){
	vector<bool> v(2000, 0);
	for (int i=0; i<k; i++) v[i] = 1;
	append_store(99, v);
	v.assign(2000, 0);
	v[0] = 1;
	append_store(98, v);
	append_left(97, 98, 1);
	if (s == 0 && n == 2 && k <= 2){
		x = 1;
		append_and(2, 0, 99);
		for (int i=0; i<n-1; i++){
			append_right(0, 0, k);
			append_and(1, 0, 99);
			comp(1, 2, true);
		}
		return;
	}
	if (s == 0){
		append_and(2, 0, 99);
		for (int i=0; i<n-1; i++){
			append_right(0, 0, k);
			append_and(1, 0, 99);
			comp(1, 2);
		}
		append_move(0, 2);
	}
	if (s == 1){
		for (int i=1; i<n; i++) append_right(i, 0, i*k);
		for (int i=0; i<n; i++) append_and(i, i, 99);
		for (int i=0; i<n; i++){
			for (int j=0; j<n-1; j++) comp(j, j+1);
		}
		for (int i=1; i<n; i++){
			append_left(0, 0, k);
			append_add(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...