#include <bits/stdc++.h>
#define ll int
#define sz(x) int(x.size())
#define forn(i, n) for (i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define fr first
#define se second
using namespace std;
void append_move(int t, int x);
void append_store(int t, std::vector<bool> v);
void append_and(int t, int x, int y);
void append_or(int t, int x, int y);
void append_xor(int t, int x, int y);
void append_not(int t, int x);
void append_left(int t, int x, int s);
void append_right(int t, int x, int s);
void append_add(int t, int x, int y);
void append_print(int t);
void construct_instructions(int s, int n, int k, int q);
void construct_instructions(int s, int n, int k, int q)
{
ll i, b=2000, j;
vector<bool>v(b,0);
for(i=0; i<k; i++)
v[i]=1;
append_store(99,v);
for(i=1; i<n; i++)
{
for(j=0; j<n-i; j++)
{
append_left(1,0,b-k*(j+1)); //solo n1
append_right(1,1,b-k); // pegar a la izquierda
append_left(2,0,b-k*(j+2)); // solo n2 y n1
append_right(2,2,b-k); // pegar a la izquierda y borrar n1
append_not(2,2); // -n2
append_add(2,1,2); // -n2+n1
append_right(2,2,b-1); // obtener signo
append_add(2,2,99); // te quedan k unos si n1>n2 o k ceros si n1<n2
append_left(2,2,b-k); // solo resultado
append_right(2,2,b-k); // pegar a la izquierda
append_not(9,2);
append_left(3,0,b-k*(j+2)); // solo n2 y n1
append_right(3,3,b-k); // pegar a la izquierda y borrar n1
append_and(5,1,9); // habilitarlo si n1 es el menor
append_and(4,3,2); // habilitarlo si n2 es el menor
append_or(6,5,4); // dejar en la pos 1 al menor
append_and(5,1,2); // habilitar n1 si es el mas grande
append_and(4,3,9); // habilitar n2 si es el mas grande
append_or(7,5,4); // dejar en la pos 1 el mas grande
append_left(7,7,k); // moverlo a la pos 2
append_or(8,7,6); // unirlos
append_right(10,0,k*(j+2)); // sacar n1 y n2 de 0
append_left(10,10,k*(j+2)); // acomodar 0
append_left(11,0,b-k*j); // sacar n1 y n2 de 0
append_right(11,11,b-k*j); // acomodar 0
append_or(0,11,10); // unir todo sin n1 ni n2
append_left(8,8,k*j); // acomodar n1 y n2
append_or(0,0,8); // volver a insertar n1 y n2 en orden
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |