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;
void construct_instructions(int s, int n, int k, int q) {
int m=100,b=2000;
vector<bool> A(b,0);
for (int i=n*k;i<b;i++) A[i]=1; append_store(99,A);
int r1=98,r2=97,A0=96,A1=95;
for (int i=0;i<b;i++) if ((i/k)%2==0) A[i]=1; else A[i]=0;
append_store(r1,A);
for (int i=0;i<b;i++) if (i%(k*2)==0) A[i]=1; else A[i]=0;
append_store(r2,A);
if (s==0) {
append_or(0,0,99);
int a=1;
while (a<n) {
append_right(1,0,a*k);
a*=2;
append_not(2,1);
append_and(2,2,r1);
append_and(0,0,r1);
append_add(3,0,2);
append_right(3,3,k);
append_and(3,3,r2);
append_add(3,3,r1);
append_and(A0,3,0);
append_not(3,3);
append_and(A1,3,1);
append_or(0,A0,A1);
}
} else {
int ANS=94,R1=93,R2=92,R3=91,R4=6,all=5;
A=vector<bool>(b,0);
for (int i=0;i<k;i++) A[i]=1;
append_store(R1,A);
for (int i=0;i<n*k;i++) A[i]=1;
append_store(all,A);
int One=89,OOne=88;
A=vector<bool>(b,0); A[0]=1; append_store(One,A);
A=vector<bool>(b,0); A[(n+1)*k]=1; append_store(OOne,A);
append_print(OOne);
A=vector<bool>(b,0); for (int i=n*k;i<(n+1)*k;i++) A[i]=1; append_store(R3,A);
A=vector<bool>(b,0); for (int i=(n+1)*k;i<(n+2)*k;i++) A[i]=1; append_store(R4,A);
for (int i=1;i<=n;i++) {
int a=1,r=90; append_move(r,0); append_or(r,r,99);
while (a<n) {
append_right(1,r,a*k);
a*=2;
append_not(2,1);
append_and(2,2,r1);
append_and(r,r,r1);
append_add(3,r,2);
append_right(3,3,k);
append_and(3,3,r2);
append_add(3,3,r1);
append_and(A0,3,r);
append_not(3,3);
append_and(A1,3,1);
append_or(r,A0,A1);
}
append_and(r,r,R1);
append_left(R2,r,(i-1)*k);
append_or(ANS,ANS,R2);
append_print(0);
int lst=85-i+1,lst2=lst-40,rub=4;
append_move(lst2,R1); append_not(lst,lst);
for (int j=1;j<=n;j++) {
append_xor(R2,r,0);
append_print(R2); // 1
append_and(R2,R2,lst2);
append_not(R2,R2);
append_and(R2,R2,all);
append_add(R2,R2,One); // n*k
append_print(R2); // 2
append_add(R2,R2,R3); // (n+1)*k;
append_print(R2); // 3
append_and(R2,R2,lst); append_move(rub,R2); append_not(rub,rub);
append_and(lst,lst,rub);
append_print(lst);
append_and(R2,R2,OOne);
append_print(R2); // 4
append_xor(R2,R2,OOne);
append_add(R2,R2,R4);
//append_print(R2);
append_right(R2,R2,(n+2)*k-j*k);
//append_print(R2);
append_and(R2,R2,lst2);
//append_print(R2);
append_or(0,0,R2);
append_left(r,r,k);
append_left(lst2,lst2,k);
}
append_print(ANS);
}
append_move(0,ANS);
}
}
Compilation message (stderr)
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:8:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
8 | for (int i=n*k;i<b;i++) A[i]=1; append_store(99,A);
| ^~~
registers.cpp:8:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
8 | for (int i=n*k;i<b;i++) A[i]=1; append_store(99,A);
| ^~~~~~~~~~~~
registers.cpp:6:6: warning: unused variable 'm' [-Wunused-variable]
6 | int m=100,b=2000;
| ^
# | 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... |