#include "registers.h"
// 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);
constexpr int EVEN = 99;
constexpr int ODD = 98;
constexpr int K = 97;
constexpr int EVEN2 = 96;
constexpr int ODD2 = 95;
void setup_registers(int n, int k)
{
std::vector<bool> v(2000);
for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) v[i*k+j] = i%2==0;
append_store(EVEN,v);
for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) v[i*k+j] = i%2==1;
append_store(ODD,v);
for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) v[i*k+j] = i==0;
append_store(K,v);
v.assign(2000,0);
for(int i = 0; i < n-1; i++) for(int j = 0; j < k; j++) v[i*k+j] = i%2==0;
append_store(EVEN2,v);
for(int i = 0; i < n-1; i++) for(int j = 0; j < k; j++) v[i*k+j] = i%2==1;
append_store(ODD2,v);
}
void construct_instructions(int s, int n, int k, int q) {
setup_registers(n,k);
// even-odd sort
for(int i = 0; i < n; i+=2)
{
// even sort, 18 instructions
append_and(1,0,EVEN);
append_and(2,0,ODD);
append_right(2,2,k);
append_not(2,2);
append_add(1,1,2);
// 1 now contains g<g<g<g<, where g is garbage and < is either all 0's or all 1's, 1s if correctly ordered
append_and(1,1,ODD);
// 1 now contains 0<0<0<...
append_right(2,1,k);
// 2 now <0<0<0<0
append_and(3,1,0); // 3 contains the parts that should be kept
append_and(4,2,0); // so does 4
append_xor(1,1,ODD);
append_xor(2,2,EVEN);
append_and(5,1,0);
append_right(5,5,k);
append_and(6,2,0);
append_left(0,6,k);
append_or(0,0,3);
append_or(0,0,4);
append_or(0,0,5);
append_and(10,0,K);
append_right(0,0,k);
append_and(1,0,EVEN2);
append_and(2,0,ODD2);
append_right(2,2,k);
append_not(2,2);
append_add(1,1,2);
// 1 now contains g<g<g<g<, where g is garbage and < is either all 0's or all 1's, 1s if correctly ordered
append_and(1,1,ODD2);
// 1 now contains 0<0<0<...
append_right(2,1,k);
// 2 now <0<0<0<0
append_and(3,1,0); // 3 contains the parts that should be kept
append_and(4,2,0); // so does 4
append_xor(1,1,ODD2);
append_xor(2,2,EVEN2);
append_and(5,1,0);
append_right(5,5,k);
append_and(6,2,0);
append_left(0,6,k);
append_or(0,0,3);
append_or(0,0,4);
append_or(0,0,5);
append_left(0,0,k);
append_or(0,0,10);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
500 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |