#include "registers.h"
#include <bits/stdc++.h>
using namespace std;
const int b = 2000, m = 100;
void construct_instructions(int s, int n, int k, int q) {
int nxt = 4;
function<int(int)> get_value = [&](int i) {
int a = nxt++;
assert(a < m);
append_left(a, 0, b - (i + 1) * k);
append_right(a, a, b - k);
return a;
};
function<int(int, int)> pos = [&](int x, int i){
int a = nxt++;
assert(a < m);
append_left(a, x, b - 1 - i);
append_right(a, a, b - 1);
return a;
};
function<int(int, int, int)> smaller = [&](int x, int y, int i){
int a = nxt++;
assert(a < m);
append_not(a, pos(x, i));
append_and(a, a, pos(y, i));
return a;
};
function<int(int, int)> get_min = [&](int x, int y) {
vector<int> v(k);
v[k - 1] = nxt++;
append_store(v[k - 1], vector<bool>(b, 0));
for (int i = k - 2; i >= 0; i--){
int a = nxt++;
append_xor(a, pos(x, i + 1), pos(y, i + 1));
append_not(a, a);
if (i < k - 2) append_and(a, v[i + 1], a);
v[i] = a;
}
int a = nxt++;
append_store(a, vector<bool>(b, 0));
for (int i = k - 1; i >= 0; i--) {
int j = smaller(x, y, i);
if (i < k - 1){
append_and(v[i], j, v[i]);
} else {
append_or(v[i], j, v[i]);
}
append_or(a, a, v[i]);
}
return a;
};
function<int(int, int)> find_min = [&](int x, int y){
int zx = get_min(x, y);
append_move(6, zx);
zx = 6;
int zy = 7;
append_not(zy, zx);
nxt = 8;
int val = nxt++;
append_store(val, vector<bool>(b, 0));
int a = nxt++;
append_print(zx);
append_print(zy);
for (int i = 0; i < k; i++){
append_and(a, pos(x, i), zx);
append_left(a, a, i);
append_add(val, val, a);
append_and(a, pos(y, i), zy);
append_left(a, a, i);
append_add(val, val, a);
}
return val;
};
nxt = 2;
int x = find_min(get_value(0), get_value(1));
append_move(1, x);
for (int i = 2; i < n; i++){
nxt = 2;
x = find_min(1, get_value(i));
append_print(x);
append_move(1, x);
}
append_move(0, 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
632 KB |
Wrong answer detected in grader |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
632 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
632 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |