#include "registers.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
const ll m = 100, b = 2000;
void construct_instructions(int s, int n, int k, int q) {
auto get_num = [&](ll t, ll x, ll i){
append_left(t,x,b-(i+1)*k);
append_right(t,t,b-k);
//append_print(t);
};
auto create_mask = [&](ll x, ll y){
vector<bool> ret(b,0);
ll c = b/(x+y);
for(ll i = 0;i<b;i++){
ret[i] = i%(x+y)<x;
}
return ret;
};
auto create_mask_d = [&](ll x, ll y,ll d){
vector<bool> ret(b,0);
ll c = b/(x+y);
for(ll i = 0;i<b;i++){
ret[i] = (i-d+x+y)%(x+y)<x;
}
return ret;
};
vector<bool> zero(b,0);
vector<bool> one(b,0);
one[0] = true;
if (s==0){
ll bn = 1<<(__lg(n-1)+1);
if (n<bn){
vector<bool> ad(b,0);
for(ll i = n;i<bn;i++) for(ll j = 0;j<k;j++) ad[i*k+j] = 1;
append_store(30,ad);
append_or(0,0,30);
}
for(ll w = k;w<k*bn;w*=2){
append_store(21,create_mask(w,w));
append_store(22,create_mask(w*2-1,1));
append_store(23,create_mask_d(w-1,w+1,1));
append_right(2,0,w);
append_and(2,21,2);
append_and(1,0,21);
if (w==1){
append_and(0,1,2);
continue;
}
append_not(3,2);
append_and(3,3,22);
append_add(5,1,3);
append_right(6,5,w-1);
append_and(6,6,23);
append_right(7,6,1);
append_or(6,7,6);
append_not(7,6);
append_and(2,2,7);
append_and(1,1,6);
append_or(0,1,2);
}
}else{
auto create_maskk = [&](ll x, ll y,ll d, ll de){
vector<bool> ret(b,0);
ll c = b/(x+y);
for(ll i = 0;i<k*n+k-de;i++){
ret[i] = (i-d+x+y)%(x+y)<x;
}
return ret;
};
append_store(21,create_maskk(k,k,0,0));
append_store(22,create_maskk(k*2-1,1,0,0));
append_store(23,create_maskk(k-1,k+1,1,0));
append_store(31,create_maskk(k,k,k,k));
append_store(32,create_maskk(k*2-1,1,k,k));
append_store(33,create_maskk(k-1,k+1,k+1,k));
append_store(40,create_maskk(k,(n-2)*k,0,0));
for(ll i = 0;i<n+10;i++){
ll tp = (i&1)*10;
append_right(2,0,k);
append_and(2,21+tp,2);
append_and(1,0,21+tp);
append_not(3,2);
append_and(3,3,22+tp);
append_add(5,1,3);
append_right(6,5,k-1);
append_and(6,6,23+tp);
append_right(7,6,1);
append_or(6,7,6);
append_not(7,6);
append_and(8,2,7);
append_and(9,1,6);
append_or(10,8,9);
append_and(8,2,6);
append_and(9,1,7);
append_or(11,8,9);
append_left(11,11,k);
if(tp){
append_and(12,0,40);
append_or(11,11,12);
}
append_or(0,10,11);
//append_print(0);
}
}
}
Compilation message
registers.cpp: In lambda function:
registers.cpp:15:6: warning: unused variable 'c' [-Wunused-variable]
15 | ll c = b/(x+y);
| ^
registers.cpp: In lambda function:
registers.cpp:23:6: warning: unused variable 'c' [-Wunused-variable]
23 | ll c = b/(x+y);
| ^
registers.cpp: In lambda function:
registers.cpp:66:7: warning: unused variable 'c' [-Wunused-variable]
66 | ll c = b/(x+y);
| ^
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:8:7: warning: variable 'get_num' set but not used [-Wunused-but-set-variable]
8 | auto get_num = [&](ll t, ll x, ll i){
| ^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Incorrect |
2 ms |
600 KB |
Incorrect sorting |
5 |
Halted |
0 ms |
0 KB |
- |