#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
#define ll long long
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);
int B=2000;
void open(int &sig, int k, int op)
{
vector<int>v;
v.pb(op);
int i;
for(i=0; i<k-1; i++)
{
sig++;
v.pb(sig);
append_right(sig,op,1);
}
sig++;
append_move(sig,op);
for(i=1; i<sz(v); i++)
{
append_or(sig,v[i],sig);
}
}
void construct_instructions(int s, int n, int k, int q)
{
int i, j, act=0, sig, uno, allUno, op, a;
append_not(1,0);
sig=1;
vector<int>pert(k);
for(i=0; i<k; i++)
{
act=k-(i+1);
vector<bool>v(B,0);
for(j=0; j<n; j++)
{
v[act]=1;
act+=k;
}
sig++;
pert[i]=sig;
append_store(sig,v);
}
vector<bool>v(B,0);
v[0]=1;
sig++;
uno=sig;
append_store(sig,v);
for(i=0; i<B; i++)
v[i]=1;
sig++;
allUno=sig;
append_store(sig,v);
for(i=0; i<k; i++)
{
sig++;
op=sig;
append_and(sig,1,pert[i]);
sig++;
append_not(sig,sig-1);
sig++;
append_add(sig,sig-1,uno);
sig++;
append_right(sig,sig-1,B-1);
sig++;
a=sig;
append_add(sig,allUno,sig-1);
open(sig, k, op);
sig++;
append_or(sig,sig-1,a);
sig++;
append_not(sig,sig-1);
append_or(0,0,sig);
}
sig++;
append_not(sig,0);
int ant, tam=n;
while(tam>1)
{
ant=tam;
tam=(tam+1)/2;
sig++;
append_move(sig,sig-1);
append_left(sig,sig,B-tam*k);
append_right(sig,sig,B-tam*k);
sig++;
append_move(sig,sig-2);
append_right(sig,sig,tam*k);
sig++;
append_or(sig,sig-1,sig-2);
}
append_not(0,sig);
/*forn(i, sig+1)
append_print(i);*/
}
# | 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... |