#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 mark(ll t, ll cant, ll &m)
{
ll pot=1, inM=m, act=m++;
while(pot*2<cant)
{
append_right(act,t,pot);
append_or(t,t,act);
pot=pot*2;
}
if(cant-pot<=0)
return;
append_right(act,t,cant-pot);
append_or(t,t,act);
}
void construct_instructions(int s, int n, int k, int q) {
ll pot=k;
while(pot<n*k)
pot*=2;
ll cer=k, act=2, i, cant=0, act2, act3, m=1;
vector<bool>v(2000,0), v2(2000), v3(2000), v4(2000), v5(2000);
for(i=n*k; i<pot; i++)
v[i]=1;
if(n*k<pot)
{
append_store(m,v);
append_or(0,m,0);
}
while(cer<pot)
{
cer=cer*2;
cant++;
}
cer=k;
while(cer<pot)
{
act=cer-1;
for(i=0; i<2000; i++)
{
v[i]=((act>=0)?0:1);
v2[i]=((act==cer-1)?0:1);
v3[i]=!v2[i];
v4[i]=((act==-cer)?1:0);
v5[i]=!v[i];
act--;
if(act<-cer)
act=cer-1;
}
append_store(m+cant*4,v5);
append_store(m+cant*3,v4);
append_store(m+cant*2,v3);
append_store(m+cant,v2);
append_store(m++,v);
cer=cer*2;
}
m=m+cant*4;
cer=k;
for(i=0; i<cant; i++)
{
act=m++;
append_and(act,0,i+1);
append_not(act,act);
append_and(act,act,i+cant+1);
act2=m++;
append_left(act2,0,cer);
append_and(act2,act2,i+1);
append_add(act2,act2,act);
append_and(act2,act2,i+1+cant*2);
append_right(act2,act2,1);
act3=m++;
append_not(act3,act2);
append_and(act3,act3,i+1+cant*3);
append_right(act3,act3,cer);
append_or(act2,act2,act3);
if(cer>k)
append_right(act2,act2,cer-k);
mark(act2,k,m);
append_and(0,0,act2);
append_right(act3,0,cer);
append_or(0,0,act3);
append_and(0,0,i+cant*4+1);
append_print(0);
cer=cer*2;
}
cer=cer/2;
act=m++;
append_right(act,0,cer);
append_or(0,act,0);
}
# | 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... |