This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "registers.h"
#include<bits/stdc++.h>
using namespace std;
const int m=100,b=2000;
int s,n,k,q;
//variables
#define ansreg 0
#define datareg 1
#define bitreg1 2
#define bitreg2 3
#define xorreg 4
#define temp1 5
#define temp2 6
#define small1 7
#define small2 8
#define mask1 9
#define mask2 10
//constants
#define zeromask 97
#define onemask 98
#define completemask 99
void moveguy(int i,int j){
append_right(i,datareg,(j+1)*k);
append_left(i,i,(j+1)*k);
append_xor(i,datareg,i);
append_right(i,i,j*k);
}
void writebit(int t,int i,int j){
append_right(t,datareg,i*k+j);
append_and(t,t,onemask);
}
void writebit(int t,int from,int i,int j){
append_right(t,from,i*k+j);
append_and(t,t,onemask);
}
void wb(int t,int from,int j){
append_right(t,from,j);
append_and(t,t,onemask);
}
void chmin(int t){
append_move(mask1,completemask);
append_move(mask2,completemask);
moveguy(temp2,t);
for(int i=k-1;0<=i;i--){
writebit(bitreg1,ansreg,0,i);
writebit(bitreg2,temp2,0,i);
append_xor(xorreg,bitreg1,bitreg2);
append_and(xorreg,xorreg,mask1);
append_and(xorreg,xorreg,mask2);
//set bit 1
append_and(bitreg1,bitreg1,xorreg);
append_add(mask1,bitreg1,mask1);
//set bit 2
append_and(bitreg2,bitreg2,xorreg);
append_add(mask2,bitreg2,mask2);
//apply mask
append_and(ansreg,ansreg,mask1);
append_and(temp2,temp2,mask2);
/*
append_print(ansreg);
append_print(temp2);
append_print(mask1);
append_print(mask2);
*/
}
append_or(ansreg,ansreg,temp2);
}
void construct_instructions(int S, int N, int K, int Q) {
s=S,n=N,k=K,q=Q;
if(!s){
append_move(datareg,0);
append_store(completemask,vector<bool>(b,1));
vector<bool>to(b,0);
to[0]=1;
append_store(onemask,to);
moveguy(ansreg,0);
for(int i=1;i<n;i++)chmin(i);
}else assert(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... |