이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 2;
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++;
assert(v[k - 1] < m);
append_store(v[k - 1], vector<bool>(b, 0));
int a = nxt++;
for (int i = k - 2; i >= 0; i--){
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;
}
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);
int zy = nxt++;
assert(zy < m);
append_not(zy, zx);
int val = nxt++;
assert(val < m);
append_store(val, vector<bool>(b, 0));
int a = nxt++;
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);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |