#include "registers.h"
#include <vector>
#include <iostream>
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(41, 40, k);
append_not(41, 41);
append_add(41, 41, ONE);
append_add(42, 40, 41); // 42 : 1-mask if a > b, else 0-mask
append_xor(43, a, b);
append_and(43, 43, 42); // 43 : a_i ^ b_i if a_i > b_i
append_xor(a, a, 43); // a_i = min(a_i, b_i)
append_xor(b, b, 43); // 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
std::cout << "finding min...";
append_print(0);
append_print(1);
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);
append_print(0);
append_print(1);
}
}
else
{
}
}
Compilation message
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'const size_t' {aka 'const long unsigned int'} [-Wsign-compare]
16 | for (int i = k; i < B; i += k)
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Possible tampering with the output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Possible tampering with the output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Possible tampering with the output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Possible tampering with the output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |