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