#include "registers.h"
#include "bits/stdc++.h"
using namespace std;
const int B=2000;
const int ONE=99;
const int ALT=98;
const int FILL=97;
void construct_instructions(int s, int n, int k, int q) {
vector<bool> b1(B),b2(B),b3(B);
for(int i=0;i<B;i+=2*k)b1[i]=1;
append_store(ONE,b1);
for(int i=0;i<B;i+=2*k)for(int j=0;j<k;j++)b2[i+j]=1;
append_store(ALT,b2);
for(int i=n*k;i<B;i++)b3[i]=1;
append_store(FILL,b3);
append_or(0,0,FILL);
while(n!=n&-n)n+=n&-n;
if(s==0){
int cnt=k;
while(n>0){
append_right(1,0,cnt);
append_and(0,0,ALT); // A
append_and(1,1,ALT); // B
append_not(2,1); // - B - 1
append_add(2,0,2); // A - B - 1
append_right(2,2,k);
append_and(2,2,ONE);
append_add(2,2,ALT);
append_and(1,1,2);
append_not(2,2);
append_and(0,0,2);
append_or(0,0,1);
n>>=1;
cnt<<=1;
}
}
}
Compilation message
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:20:9: warning: self-comparison always evaluates to false [-Wtautological-compare]
20 | while(n!=n&-n)n+=n&-n;
| ~^~~
registers.cpp:20:9: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
20 | while(n!=n&-n)n+=n&-n;
| ~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |