#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 pot=k, i, act=1, j, m=1;
while(pot<n*k)
pot*=2;
vector<bool>v(2000,0);
for(i=n*k; i<pot; i++)
v[i]=1;
if(n*k<pot)
{
append_store(m,v);
append_or(0,m,0);
}
while(act<n)
{
act*=2;
v.resize(0);
v.resize(2000,0);
for(i=0; i<n; i++)
{
if(i%act)
{
for(j=0; j<k; j++)
v[i*k+j]=0;
}
else
{
for(j=0; j<k; j++)
v[i*k+j]=1;
}
}
append_store(1,v); // deshabilitar impares (comando)
append_and(2,1,0); // par
append_xor(3,2,0); // impar
append_right(3,3,k*(act/2)); // alinear
append_xor(3,3,1); // negar impar
append_add(4,3,2); // -impar+par
append_right(4,4,k); // alinear signo al inicio
append_and(4,1,4); // solo dejar los signos y nada de basura
append_add(4,1,4); // deja en 0 las posiciones donde el par era mas grande
append_and(2,4,2); // solo dejamos habilitados los pares mas chicos
append_not(4,4); // negamos para dejar en 1 las posiciones donde el par era el mas grande
append_xor(3,3,1);
append_and(3,4,3); // solo dejamos habilitado los impares mas chicos
append_or(0,3,2); // dejamos los numeros mas chicos
}
}
# | 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... |