#include "registers.h"
void solv0(int n, int k ,int q){
int bit;
if(n==2) bit=1;
else bit=7;
int tot=(1<<bit);
// set 1 for a[n+1]~a[2^bit-1]
vector <bool> v0(2000, false);
for(int i=n*k;i<tot*k;i++) v0[i]=true;
append_store(50, v0);
append_or(0, 0, 50);
for(int i=0;i<bit;i++){
vector <bool> v1(2000, false), v2(2000, false);
for(int j=0;j<tot;j++){
if(j%(1<<(i+1))==0){
for(int z=j*k;z<(j+1)*k;z++) v1[j]=true;
}
else if(j%(1<<i)==0){
for(int z=j*k;z<(j+1)*k;z++) v2[j]=true;
}
}
// 1: 2^(i+1)x번째 값, 2: 2^(i+1)x+2^i번째 값
append_store(51, v1);
append_store(52, v2);
append_move(1, 0);
append_move(2, 0);
append_and(1, 1, 51);
append_and(2, 2, 52);
append_shift_left(2, 2, (1<<i)*k);
// 3: !2, 4: 1+3의 k+1번째 자리
//!y = 2^b-1 - y
// x + !y < 2^b <=> x+2^b-1-y < 2^b <=> x-y-1<0 <=> x<=y
// k+1번째 자리가 0 <=> x<=y
append_not(3, 2);
append_and(3, 3, 51);
append_add(4, 1, 3);
vector <bool> v3(2000, false);
for(int j=0;j<tot;j++){
if(j%(1<<(i+1))==0) v3[(j+1)*k]=true;
}
append_store(53, v3);
append_and(4, 4, 53);
append_shift_left(4, 4, k);
//5: 0 -> 1111, 1 -> 0000, 6: !5
append_add(5, 4, 51);
append_and(5, 5, 51);
append_not(6, 5);
append_and(6, 6, 51);
//0: 5&1+6&2
append_and(7, 5, 1);
append_and(8, 6, 2);
append_add(0, 7, 8);
}
}
void construct_instructions(int s, int n, int k, int q) {
if(s==0){
solv0(n, k, q);
}
}
Compilation message
registers.cpp: In function 'void solv0(int, int, int)':
registers.cpp:9:5: error: 'vector' was not declared in this scope
9 | vector <bool> v0(2000, false);
| ^~~~~~
registers.cpp:9:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
from registers.h:1,
from registers.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector'
389 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
In file included from registers.h:1,
from registers.cpp:1:
/usr/include/c++/10/vector:86:13: note: 'std::pmr::vector'
86 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
registers.cpp:9:13: error: expected primary-expression before 'bool'
9 | vector <bool> v0(2000, false);
| ^~~~
registers.cpp:10:32: error: 'v0' was not declared in this scope
10 | for(int i=n*k;i<tot*k;i++) v0[i]=true;
| ^~
registers.cpp:11:22: error: 'v0' was not declared in this scope
11 | append_store(50, v0);
| ^~
registers.cpp:14:17: error: expected primary-expression before 'bool'
14 | vector <bool> v1(2000, false), v2(2000, false);
| ^~~~
registers.cpp:17:46: error: 'v1' was not declared in this scope
17 | for(int z=j*k;z<(j+1)*k;z++) v1[j]=true;
| ^~
registers.cpp:20:46: error: 'v2' was not declared in this scope
20 | for(int z=j*k;z<(j+1)*k;z++) v2[j]=true;
| ^~
registers.cpp:24:26: error: 'v1' was not declared in this scope
24 | append_store(51, v1);
| ^~
registers.cpp:25:26: error: 'v2' was not declared in this scope
25 | append_store(52, v2);
| ^~
registers.cpp:30:9: error: 'append_shift_left' was not declared in this scope; did you mean 'append_left'?
30 | append_shift_left(2, 2, (1<<i)*k);
| ^~~~~~~~~~~~~~~~~
| append_left
registers.cpp:38:17: error: expected primary-expression before 'bool'
38 | vector <bool> v3(2000, false);
| ^~~~
registers.cpp:40:33: error: 'v3' was not declared in this scope
40 | if(j%(1<<(i+1))==0) v3[(j+1)*k]=true;
| ^~
registers.cpp:42:26: error: 'v3' was not declared in this scope
42 | append_store(53, v3);
| ^~