#include "registers.h"
#include <bits/stdc++.h>
using namespace std;
int b = 2000;
void construct_instructions(int s, int n, int k, int q) {
if(s == 0){
vector<bool> d(b);
vector<bool> qq(b);
while(__builtin_popcount(n) > 1){
for(int j = 0 ; j < k ; j ++ ){
d[n * k + j] = 1;
}
n ++ ;
}
for(int i = 0 ; i < b; i ++ ){
if((i / k) % 2 == 0){
qq[i] = 1;
}
else{
qq[i] = 0;
}
}
vector<bool> zz(b);
for(int i = 0 ; i < b; i ++ ){
if(i > 0 && i % k == 0) zz[i] = 1;
}
append_store(8, zz);
vector<bool> emp(b);
append_store(1, d);
append_store(4, qq);
append_or(0, 0, 1);
int b = 0;
while((1 << b) < n) b ++ ;
for(int j = 0 ; j < b; j ++ ){
append_right(3, 0, (k << j));
append_move(2, 0);
append_not(3, 3);
append_and(2, 2, 4);
append_and(3, 3, 4);
append_add(5, 2, 3);
append_store(6, emp);
append_and(5, 5, 8);
append_right(5, 5, k);
append_add(5, 5, 4);
//append_print(5);
append_not(3, 3);
append_and(3, 3, 4);
append_and(2, 2, 5);
append_not(5, 5);
append_and(3, 3, 5);
append_or(0, 2, 3);
}
}
else{
vector<bool> Z(b);
for(int i = 0 ; i < k ; i ++ ){
Z[n * k + i] = 1;
Z[(n + 1) * k + i] = 1;
}
vector<bool> iq(b);
vector<bool> kk(b);
for(int i = 0 ; i < b; i ++ ){
if((i / k) % 2 == 0)
iq[i] = 1;
else
iq[i] = 0;
if((i % k == 0) && i > 0) kk[i] = 1;
}
vector<bool> ff(b);
for(int i = 0 ; i < k ; i ++ )
ff[i] = 1;
append_store(97, Z);
append_store(99, iq);
append_store(98, kk);
append_store(96, ff);
for(int s = 0; s < n; s ++ ){
if(s % 2 == 0){
append_or(0, 0, 97);
append_move(1, 0);
append_right(2, 0, k);
append_not(2, 2);
append_and(1, 1, 99);
append_and(2, 2, 99);
append_add(3, 1, 2);
append_not(2, 2);
append_and(2, 2, 99);
append_and(3, 3, 98);
append_right(3, 3, k);
append_add(3, 3, 99);
append_xor(4, 1, 2);
append_and(4, 3, 4);
append_xor(1, 1, 4);
append_xor(2, 2, 4);
append_left(1, 1, k);
append_or(0, 1, 2);
}
else{
append_or(0, 0, 97);
append_right(1, 0, k);
append_right(2, 0, 2 * k);
append_not(2, 2);
append_and(1, 1, 99);
append_and(2, 2, 99);
append_add(3, 1, 2);
append_not(2, 2);
append_and(2, 2, 99);
append_and(3, 3, 98);
append_right(3, 3, k);
append_add(3, 3, 99);
append_xor(4, 1, 2);
append_and(4, 3, 4);
append_xor(1, 1, 4);
append_xor(2, 2, 4);
append_and(0, 0, 96);
append_left(1, 1, 2 * k);
append_left(2, 2, k);
append_or(0, 0, 1);
append_or(0, 0, 2);
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |