#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll inf = 1e9;
const int md1 = 1e9+7;
const int md2 = 998244353;
#define sz(v) ((int)v.size())
#define pb push_back
#define pry cout << "YES\n"
#define prn cout << "NO\n"
#define endl '\n'
#define fst first
#define scn second
#define clear for (i = 0; i < B; ++i) { v[i] = 0; }
const int D = 99; // del extra
const int L = 98; // last bit
const int S = 97; // for sum
const int N = 96; // min
const int X = 95; // max
const int F = 94; // diff
const int T = 93; // temporary
/* #define ONPC */
const int B = 2000;
const int M = 100;
void append_move(int t, int y);
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
fminmax(int a, int b, int k)
{
append_not(F, b);
append_and(F ,F, D);
append_add(F ,F, S);
append_add(F ,F, a);
append_and(F ,F, L);
/* TODO improve */
for (int j = 0; j < k; ++j) {
append_right(N, F, 1);
append_or(F,F,N);
}
append_and(X, F, a);
append_and(N, F, b);
append_not(F,F);
append_and(T, F, a);
append_or(N, N, T);
append_and(T, F, b);
append_or(X, X, T);
return;
}
void
construct_instructions(int s, int n, int k, int q)
{
int i, j, l;
assert(!s);
vector<bool> v(B, 0);
if (n&1) {
for (i = 0; i < k; ++i)
v[n*k + i] = 1;
append_store(1,v);
append_or(0,0,1);
++n;
}
clear;
for (i = 0; i < n; ++i) {
if (i&1) continue;
for (j = 0; j < k; ++j) v[i*k+j] = 1;
}
append_store(D,v); clear;
for (i = 0; i < n; ++i) {
if (i&1) continue;
v[i*k+k] = 1;
}
append_store(L,v); clear;
for (i = 0; i < n; ++i) {
if (i&1) continue;
v[i*k] = 1;
}
append_store(S,v); clear;
append_and(1, 0, D);
append_right(2, 0, k);
append_and(2, 2, D);
fminmax(1,2,k);
append_move(0,N);
return;
}
vector<bitset<B>> r(M);
void append_move(int t, int y){
r[t] = r[y];
}
void append_store(int t, vector<bool> v){
for (int i = 0; i < B; ++i) r[t][i] = v[i];
}
void append_and(int t, int x, int y){
r[t] = (r[x]&r[y]);
}
void append_or(int t, int x, int y){
r[t] = (r[x]|r[y]);
}
void append_xor(int t, int x, int y){
r[t] = (r[x]^r[y]);
}
void append_not(int t, int x){
r[t] = (~r[x]);
}
void append_left(int t, int x, int p){
r[t] = (r[x]<<p);
}
void append_right(int t, int x, int p){
r[t] = (r[x]>>p);
}
void append_add(int t, int x, int y){
bitset<B> tmp;
bool ex = 0;
int cnt;
for (int i = 0; i < B; ++i) {
tmp[i] = (r[x][i]^r[y][i]^ex);
cnt = 0;
if (r[x][i]) ++cnt;
if (r[y][i]) ++cnt;
if (ex) ++cnt;
ex = (cnt > 1);
}
r[t] = tmp;
}
void
solve()
{
for (int i = 0; i < M; ++i) {
for (int j = 0; j < B; ++j) {
r[i][j] = 0;
}
}
int n, k, x;
cin >> n >> k;
for (int i = 0; i < n; ++i) {
cin >> x;
for (int j = 0; j < k; ++j)
if ((x>>j)&1) r[0][i*k+j] = 1;
}
construct_instructions(0,n,k,100);
int ans = 0;
for (int i = 0; i < k; ++i) {
if (r[0][i]) ans |= (1<<i);
}
cout << ans << endl;
}
int32_t
main(int argc, char **argv)
{
if (argc >= 2) {
freopen(argv[1], "r", stdin);
} else
ios_base::sync_with_stdio(0);cin.tie(0);
int t = 1;
/* cin >> t; */
while(t--)
solve();
}
#ifdef ONPC
#endif
Compilation message
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:71:15: warning: unused variable 'l' [-Wunused-variable]
71 | int i, j, l;
| ^
registers.cpp: In function 'int32_t main(int, char**)':
registers.cpp:197:7: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
197 | } else
| ^~~~
registers.cpp:198:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
198 | ios_base::sync_with_stdio(0);cin.tie(0);
| ^~~
registers.cpp:196:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
196 | freopen(argv[1], "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccSfivN1.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccj6mOj2.o:registers.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_store(int, std::vector<bool, std::allocator<bool> >)':
grader.cpp:(.text+0x2a0): multiple definition of `append_store(int, std::vector<bool, std::allocator<bool> >)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0xe0): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_not(int, int)':
grader.cpp:(.text+0x5c0): multiple definition of `append_not(int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0x7d0): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_move(int, int)':
grader.cpp:(.text+0x790): multiple definition of `append_move(int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_or(int, int, int)':
grader.cpp:(.text+0x960): multiple definition of `append_or(int, int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0x370): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_add(int, int, int)':
grader.cpp:(.text+0xb60): multiple definition of `append_add(int, int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0x1110): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_xor(int, int, int)':
grader.cpp:(.text+0xd60): multiple definition of `append_xor(int, int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0x5a0): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_and(int, int, int)':
grader.cpp:(.text+0xf60): multiple definition of `append_and(int, int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0x140): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_left(int, int, int)':
grader.cpp:(.text+0x1160): multiple definition of `append_left(int, int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0xa30): first defined here
/usr/bin/ld: /tmp/ccSfivN1.o: in function `append_right(int, int, int)':
grader.cpp:(.text+0x1360): multiple definition of `append_right(int, int, int)'; /tmp/ccj6mOj2.o:registers.cpp:(.text+0xdb0): first defined here
collect2: error: ld returned 1 exit status