#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
template<class X, class Y>
inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
const int MAXM = 100;
const int MAXB = 2000;
int nArr, k, maxInstr;
#ifdef Nhoksocqt1
bool regs[MAXM][MAXB];
void append_move(int t, int x);
void append_store(int t, vector<bool> v);
void append_and(int t, int x, int y);
void append_or(int t, int x, int y);
void append_xor(int t, int x, int y);
void append_not(int t, int x);
void append_left(int t, int x, int p);
void append_right(int t, int x, int p);
void append_add(int t, int x, int y);
void append_print(int t);
#endif // Nhoksocqt1
void findMinElement(void) {
vector<bool> v(MAXB, 1);
append_store(1, v);
for (int i = k; i < MAXB; ++i)
v[i] = 0;
append_store(2, v);
append_and(10, 0, 2);
for (int i = 1; i < nArr; ++i) {
append_xor(9, 10, 1);
append_right(3, 0, i * k);
append_and(3, 3, 2);
append_add(4, 3, 9);
append_right(4, 4, MAXB - k);
append_and(3, 3, 4);
append_xor(4, 4, 2);
append_and(10, 10, 4);
append_or(10, 10, 3);
}
append_print(10);
}
void construct_instructions(int queryType, int _N, int _K, int _Q) {
nArr = _N, k = _K, maxInstr = _Q;
if(queryType == 0)
findMinElement();
}
#ifdef Nhoksocqt1
void append_move(int t, int x) {
assert(0 <= min({t, x}) && max({t, x}) < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = regs[x][i];
}
void append_store(int t, vector<bool> v) {
assert(sz(v) == MAXB);
assert(0 <= t && t < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = v[i];
}
void append_and(int t, int x, int y) {
assert(0 <= min({t, x, y}) && max({t, x, y}) < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = regs[x][i] & regs[y][i];
}
void append_or(int t, int x, int y) {
assert(0 <= min({t, x, y}) && max({t, x, y}) < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = regs[x][i] | regs[y][i];
}
void append_xor(int t, int x, int y) {
assert(0 <= min({t, x, y}) && max({t, x, y}) < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = regs[x][i] ^ regs[y][i];
}
void append_not(int t, int x) {
assert(0 <= min({t, x}) && max({t, x}) < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = 1 - regs[x][i];
}
void append_left(int t, int x, int p) {
assert(0 <= p && p <= MAXB);
assert(0 <= min({t, x}) && max({t, x}) < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = (i < p) ? 0 : regs[x][i - p];
}
void append_right(int t, int x, int p) {
assert(0 <= p && p <= MAXB);
assert(0 <= min({t, x}) && max({t, x}) < MAXB);
for (int i = 0; i < MAXB; ++i)
regs[t][i] = (i + p >= MAXB) ? 0 : regs[x][i + p];
}
void append_add(int t, int x, int y) {
assert(0 <= min({t, x, y}) && max({t, x, y}) < MAXB);
__int128 a(0), b(0), pw2(1);
for (int i = 0; i < MAXB; ++i) {
a += pw2 * regs[x][i];
b += pw2 * regs[y][i];
pw2 *= 2;
}
a += b;
for (int i = 0; i < MAXB; ++i) {
regs[t][i] = a % 2;
a /= 2;
}
}
void append_print(int t) {
cout << "ANSWER: ";
for (int i = 0; i < nArr; ++i) {
int res(0);
for (int j = 0; j < k; ++j)
res |= (1 << j) * regs[t][i * k + j];
cout << res << ' ';
}
cout << '\n';
}
int main(void) {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TASK "registers"
if(fopen(TASK".inp", "r")) {
freopen(TASK".inp", "r", stdin);
freopen(TASK".out", "w", stdout);
}
int s, n, k, q;
cin >> s >> n >> k >> q;
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
for (int j = 0; j < k; ++j)
regs[0][i * k + j] = (a >> j & 1);
}
construct_instructions(s, n, k, q);
return 0;
}
#endif // Nhoksocqt1
Compilation message
registers.cpp: In function 'void findMinElement()':
registers.cpp:44:5: error: 'append_store' was not declared in this scope
44 | append_store(1, v);
| ^~~~~~~~~~~~
registers.cpp:50:5: error: 'append_and' was not declared in this scope
50 | append_and(10, 0, 2);
| ^~~~~~~~~~
registers.cpp:52:9: error: 'append_xor' was not declared in this scope
52 | append_xor(9, 10, 1);
| ^~~~~~~~~~
registers.cpp:53:9: error: 'append_right' was not declared in this scope
53 | append_right(3, 0, i * k);
| ^~~~~~~~~~~~
registers.cpp:55:9: error: 'append_add' was not declared in this scope
55 | append_add(4, 3, 9);
| ^~~~~~~~~~
registers.cpp:61:9: error: 'append_or' was not declared in this scope
61 | append_or(10, 10, 3);
| ^~~~~~~~~
registers.cpp:64:5: error: 'append_print' was not declared in this scope
64 | append_print(10);
| ^~~~~~~~~~~~