#include "registers.h"
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
const int mxn = 2010;
int ru = 1;
vector<bool> fa[100];
void construct_instructions(int s, int n, int k, int q)
{
int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1,f4,f5;
if(s == 0)
{
if(k == 1)
{
cn = 0;
for(i=6; i>=0; i--)
{
if((1<<i) < n)
{
if(1<<(i+1) >= n)
append_right(ru,cn,(n - (1<<i)));
else
{
append_right(ru,cn,(1<<i));
}
cm = ru;
ru ++;
append_and(cn,cn,cm);
}
}
return ;
}
cn = 0;
ru = 1;
for(j=0; j<n; j++)
{
if(j%2 == 0)
{
fa[2].push_back(0);
fa[3].push_back(1);
for(o=0; o<k; o++)
{
fa[0].push_back(0);
fa[1].push_back(1);
if(o > 0)
{
fa[2].push_back(0);
fa[3].push_back(0);
}
}
}
else
{
fa[2].push_back(1);
fa[3].push_back(0);
for(o=0; o<k; o++)
{
fa[0].push_back(1);
fa[1].push_back(0);
if(o > 0)
{
fa[2].push_back(0);
fa[3].push_back(0);
}
}
}
}
for(j=n*k; j<2000; j++)
{
fa[0].push_back(0);
fa[1].push_back(0);
}
fa[1][n*k] = 1;
append_store(ru,fa[0]);
append_store(ru+1,fa[1]);
f0 = ru;
f1 = ru+1;
ru += 2;
for(i=6; i>=0; i--)
{
if((1<<i) < n)
{
ru = 3;
if(1<<(i+1) >= n)
append_right(ru,cn,k*(n - (1<<i)));
else
{
append_right(ru,cn,k*(1<<i));
}
cm = ru;
ru ++;
append_print(cm);
cle = (1<<i);
// fa[0].clear();
// fa[1].clear();
// for(j=0; j<cle; j++)
// {
// if(j%2 == 0)
// {
// fa[2].push_back(0);
// fa[3].push_back(1);
// for(o=0; o<k; o++)
// {
// fa[0].push_back(0);
// fa[1].push_back(1);
// if(o > 0)
// {
// fa[2].push_back(0);
// fa[3].push_back(0);
// }
// }
// }
// else
// {
// fa[2].push_back(1);
// fa[3].push_back(0);
// for(o=0; o<k; o++)
// {
// fa[0].push_back(1);
// fa[1].push_back(0);
// if(o > 0)
// {
// fa[2].push_back(0);
// fa[3].push_back(0);
// }
// }
// }
// }
// for(j=cle*k; j<2000; j++)
// {
// fa[0].push_back(0);
// fa[1].push_back(0);
// }
// fa[1][cle*k] = 1;
// append_store(ru,fa[0]);
// append_store(ru+1,fa[1]);
// append_not(ru+2,cm);
append_and(ru+3,cn,f0);
append_and(ru+4,cm,f0);
append_and(ru+5,cn,f1);
append_and(ru+6,cm,f1);
append_not(ru+7,ru+4);
append_not(ru+8,ru+6);
append_add(ru+9,ru+3,ru+7);
append_add(ru+10,ru+5,ru+8);
append_and(ru+11,ru+9,f1);
append_and(ru+12,ru+10,f0);
append_or(ru+13,ru+11,ru+12);
append_right(ru+14,ru+13,k);
for(j=2; j<15; j++)
{
append_print(ru+j);
}
fn = ru+14;
// for(j=0; j<4; j++)
// {
// if((1<<(j+1)) < k)
// {
// append_left(fn+1,fn,(1<<j));
// append_or(fn,fn,fn+1);
// }
// else
// {
// append_left(fn+1,fn,k-(1<<j));
// append_or(fn,fn,fn+1);
// break;
// }
// }
append_and(fn+2,fn,cn);
append_not(fn+3,fn);
append_and(fn+4,fn+3,cm);
append_or(0,fn+2,fn+4);
for(j=0; j<5; j++)
{
append_print(fn+j);
}
cn = 0;
append_print(0);
}
}
return ;
}
else
{
cn = 0;
ru = 1;
for(j=0; j<n; j++)
{
if(j%2 == 0)
{
fa[2].push_back(0);
fa[3].push_back(1);
for(o=0; o<k; o++)
{
fa[0].push_back(0);
fa[1].push_back(1);
if(o > 0)
{
fa[2].push_back(0);
fa[3].push_back(0);
}
}
}
else
{
fa[2].push_back(1);
fa[3].push_back(0);
for(o=0; o<k; o++)
{
fa[0].push_back(1);
fa[1].push_back(0);
if(o > 0)
{
fa[2].push_back(0);
fa[3].push_back(0);
}
}
}
}
for(j=n*k; j<2000; j++)
{
fa[0].push_back(0);
fa[1].push_back(0);
}
for(j=n*k; j<(n+1)*k; j++)
{
fa[1][j] = 1;
}
append_store(ru,fa[0]);
append_store(ru+1,fa[1]);
f0 = ru;
f1 = ru+1;
ru += 2;
for(i=0; i<(n)*k; i++)
{
fa[4].push_back(0);
}
for(i=0; i<k; i++)
{
fa[4].push_back(1);
}
for(i=(n+1)*k; i<2000; i++)
{
fa[4].push_back(0);
}
append_store(ru,fa[4]);
f4 = ru;
ru ++;
// append_or(0,ru,0);
for(i=0; i<k; i++)
{
fa[5].push_back(1);
}
for(i=k; i<2000; i++)
{
fa[5].push_back(0);
}
append_store(ru,fa[5]);
f5 = ru;
ru ++;
for(i=0; i<n; i++)
{
append_or(0,0,f4);
ru = 10;
append_right(ru,cn,k);
cm = ru;
ru ++;
if(i % 2 == 0)
{
append_and(ru,cn,f1);
append_and(ru+1,cm,f1);
append_not(ru+2,ru+1);
append_add(ru+3,ru,ru+2);
append_and(ru+4,ru+3,f0);
append_right(ru+5,ru+4,k);
append_not(ru+6,ru+5);
append_and(ru+7,ru+5,ru);
append_and(ru+8,ru+6,ru+1);
append_or(ru+9,ru+7,ru+8);
append_and(ru+10,ru+5,ru+1);
append_and(ru+11,ru+6,ru);
append_or(ru+12,ru+10,ru+11);
append_left(ru+13,ru+12,k);
append_or(0,ru+9,ru+13);
}
else
{
append_and(ru,cn,f0);
append_and(ru+1,cm,f0);
append_not(ru+2,ru+1);
append_add(ru+3,ru,ru+2);
append_and(ru+4,ru+3,f1);
append_right(ru+5,ru+4,k);
append_not(ru+6,ru+5);
append_and(ru+7,ru+5,ru);
append_and(ru+8,ru+6,ru+1);
append_or(ru+9,ru+7,ru+8);
append_and(ru+10,ru+5,ru+1);
append_and(ru+11,ru+6,ru);
append_or(ru+12,ru+10,ru+11);
append_left(ru+13,ru+12,k);
append_and(ru+14,cn,f5);
append_or(ru+15,ru+13,ru+14);
append_or(0,ru+9,ru+15);
}
for(j=0; j<16; j++)
{
append_print(ru+j);
}
append_print(0);
cn = 0;
}
return ;
}
append_move(1, 0);
append_right(1, 1, 1);
append_and(0, 0, 1);
}
Compilation message
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:11:19: warning: unused variable 'fm' [-Wunused-variable]
11 | int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1,f4,f5;
| ^~
registers.cpp:11:22: warning: variable 'cle' set but not used [-Wunused-but-set-variable]
11 | int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1,f4,f5;
| ^~~
registers.cpp:11:28: warning: unused variable 'p' [-Wunused-variable]
11 | int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1,f4,f5;
| ^
registers.cpp:11:30: warning: unused variable 'h' [-Wunused-variable]
11 | int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1,f4,f5;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Incorrect |
2 ms |
428 KB |
Incorrect sorting |
5 |
Halted |
0 ms |
0 KB |
- |