#include "registers.h"
#include<bits/stdc++.h>
using namespace std;
void policz_mniejsze(int k, int skip, int n){
vector<bool>zero(2000, 0);
int i;
for(i=0;i<2000;i+=k*skip*2)
zero[i] = 1;
append_store(10, zero);
for(int j=0;j<n;j+=skip*2)
for(int i=0;i<k;i++)
zero[j*k+i] = 1;
append_store(11, zero);
//0 - a
//1 - b
//2 - !a
append_right(1, 0, k*skip);
append_and(0,11,0);
append_and(1,11,1);
append_not(2, 0);
append_and(2, 2, 11);
append_add(2, 1, 2);
append_right(2, 2, k);
append_and(2, 2, 10);//0 lub 1
append_add(2, 2, 11); //11111 lub 0000
append_and(3, 1, 2);
append_and(4, 0, 2);
append_xor(4, 0, 4);
append_or(2, 3, 4);
append_xor(1, 0, 1);
append_move(0, 2);
append_xor(1, 0, 1);
// append_left(1, 1, k);
// append_or(0, 1, 0);
}
void popraw(int k, int n){
append_print(0);
append_print(1);
append_not(2, 0);
append_and(2, 2, 99);
append_add(2, 1, 2);
append_right(2, 2, k);
append_and(2, 2, 10);//0 lub 1
append_add(2, 2, 99); //11111 lub 0000
append_and(3, 1, 2);
append_and(4, 0, 2);
append_xor(4, 0, 4);
append_or(2, 3, 4);
append_print(2);
append_xor(1, 0, 1);
append_move(0, 2);
append_xor(1, 0, 1);
// append_left(1, 1, k);
// append_or(0, 1, 0);
append_print(0);
append_print(1);
}
void popraw1(int k, int n){
append_print(0);
append_print(1);
vector<bool>pom(2000, 0);
for(int i=0;i<k;i++)
pom[n*k+i] = 1;
append_store(97, pom);
append_or(0, 0, 97);
append_not(2, 0);
append_and(2, 2, 99);
append_add(2, 1, 2);
append_right(2, 2, k);
append_and(2, 2, 10);//0 lub 1
append_add(2, 2, 99); //11111 lub 0000
append_and(3, 1, 2);
append_and(4, 0, 2);
append_xor(4, 0, 4);
append_or(2, 3, 4);
append_print(2);
append_xor(0, 0, 1);
append_move(1, 2);
append_xor(0, 0, 1);
// append_left(1, 1, k);
// append_or(0, 1, 0);
append_print(0);
append_print(1);
}
void construct_instructions(int s, int n, int k, int q) {
if(s==0){
vector<bool>zero(2000, 0);
int pot = 1;
while(pot<n)
pot*=2;
for(int i=k*n;i<pot*k;i++)
zero[i] = 1;
// for(auto j: zero)printf("%d", (int)j);printf("\n");
n = pot;
append_store(1, zero);
append_or(0, 0, 1);
// append_print(0);
int skip = 1;
while(skip<n){
policz_mniejsze(k, skip, n);
append_print(0);
skip*=2;
}
return;
}
vector<bool>zero(2000, 0);
int pot = 1;
while(pot<n)
pot*=2;
for(int i=k*n;i<pot*k;i++)
zero[i] = 1;
// for(auto j: zero)printf("%d", (int)j);printf("\n");
n = pot;
append_store(1, zero);
append_or(0, 0, 1);
// append_print(0);
for(int i=0;i<2000;i++)zero[i] = 0;
for(int i=0;i<2000;i+=k*2)
zero[i] = 1;
append_store(10, zero);
for(int i=0;i<130*k;i++)
zero[i] = (i/k)%2;
append_store(99, zero);
append_and(1, 0, 99);
append_right(1, 1, k);
append_right(99,99,k);
append_and(0,0,99);
for(int i=0;i<2000;i++)zero[i] = 0;
for(int i=0;i<k;i++)
zero[n*k+i] = 1;
append_store(98, zero);
append_or(1, 1, 98);
append_print(0);
append_print(1);
for(int j=0;j<n;j++){
popraw1(k, n);
append_left(0, 0, 2*k);
popraw(k, n);
append_right(0, 0, 2*k);
}
append_left(0, 0, k);
append_or(0, 1, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
436 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
1040 KB |
Output is correct |
4 |
Correct |
4 ms |
1040 KB |
Output is correct |
5 |
Correct |
2 ms |
1040 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |