#include "registers.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
int M=100,B=2000;
vector<bool> v(2000);
void construct_instructions(int s, int n, int k, int q)
{
for(int bit=k-1;bit>0;bit--)
{
for(int i=0;i<n;i++)
for(int j=0;j<k;j++)
{
v[i*k+j]=0;
if(j==bit)
v[i*k+j]=1;
}
append_store(1,v);
append_and(2,0,1);
if(bit!=0)
append_right(2,2,bit);
int poz=2;
for(int lg=2;lg<=bit+1;lg*=2)
{
append_left(poz+1,poz,lg/2);
append_add(poz+1,poz+1,poz);
poz++;
}
int mask;
if(bit==1)
mask=3;
if(bit==2)
{
append_left(2,2,2);
append_add(3,3,2);
mask=3;
}
if(bit==3)
mask=4;
if(bit==4)
{
append_left(2,2,4);
append_add(4,4,2);
mask=4;
}
if(bit==5)
{
append_left(3,3,4);
append_add(4,3,4);
mask=4;
}
if(bit==6)
{
append_left(3,3,4);
append_add(4,3,4);
append_left(2,2,6);
append_add(4,2,4);
mask=4;
}
if(bit==7)
mask=5;
if(bit==8)
{
append_left(2,2,8);
append_add(5,5,2);
mask=5;
}
if(bit==9)
{
append_left(3,3,8);
append_add(5,5,3);
mask=5;
}
for(int i=0;i<v.size();i++)
v[i]=0;
v[0]=1;
append_store(50,v);
for(int p=0;p<n;p++)
{
append_right(20,mask,p*k+bit);
append_and(50,50,20);
//append_left(50,50,B-1);
//append_right(50,50,B-1);
}
append_not(50,50);
append_left(50,50,B-1);
append_right(50,50,B-1);
for(int lg=2;lg<=n;lg*=2)
{
append_left(51,50,lg/2);
append_add(50,50,51);
}
append_and(mask,mask,50);
append_or(0,0,mask);
}
int lg=n;
while(lg>1)
{
int newlg=lg/2+lg%2;
append_right(1,0,newlg*k);
if(lg%2==1)
{
for(int i=0;i<n;i++)
for(int j=0;j<k;j++)
{
v[i*k+j]=0;
if(i==newlg-1)
v[i*k+j]=1;
}
append_store(3,v);
append_add(1,1,3);
}
append_and(0,0,1);
lg=newlg;
}
}
Compilation message
registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:74:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
registers.cpp:94:18: warning: 'mask' may be used uninitialized in this function [-Wmaybe-uninitialized]
94 | append_or(0,0,mask);
| ~~~~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |