#include "registers.h"
#include <vector>
constexpr size_t B = 2000;
constexpr int ONE = 50, ALL_ONES = 51, MASK = 52;
void construct_instructions(int s, int n, int k, int q)
{
std::vector<bool> r(B);
r[0] = 1;
append_store(ONE, r);
fill(r.begin() + 1, r.end(), 1);
append_store(ALL_ONES, r);
fill(r.begin(), r.end(), 0);
for (int i = k; i < B; i += k)
r[i] = 1;
append_store(MASK, r);
// writes min in a, max in b
auto append_swap = [&](int a, int b)
{
append_not(40, a);
append_add(40, 40, ONE);
append_add(40, 40, b); // 40 : b - a
append_xor(41, 40, a);
append_xor(41, 41, b); // 41 : (b - a) ^ a ^ b
append_and(40, 41, MASK);
append_right(40, 40, k);
append_not(40, 40);
append_add(40, 40, ONE); // 40 : 1-mask if a > b, else 0-mask
append_xor(41, a, b);
append_and(42, 40, 41); // 42 : a_i ^ b_i if a_i > b_i
append_xor(a, a, 42); // a_i = min(a_i, b_i)
append_xor(b, b, 42); // b_i = max(a_i, b_I)
};
if (!s)
{
int l = 64;
append_left(2, ALL_ONES, n * k);
append_or(0, 0, 2);
append_move(1, 0);
append_right(0, 0, l * k); // 0 : upper half
append_left(2, ALL_ONES, l * k);
append_or(1, 1, 2); // 1 : lower half
while (l)
{
append_swap(0, 1);
l >>= 1;
append_move(1, 0);
append_right(0, 0, l * k);
append_left(2, ALL_ONES, l * k);
append_or(1, 1, 2);
}
}
else
{
}
}
Compilation message
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'const size_t' {aka 'const long unsigned int'} [-Wsign-compare]
15 | for (int i = k; i < B; i += k)
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
284 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |