#include "registers.h"
#include <bits/stdc++.h>
using namespace std;
#define OP_MOVE 0
#define OP_STORE 1
#define OP_AND 2
#define OP_OR 3
#define OP_XOR 4
#define OP_NOT 5
#define OP_LEFT 6
#define OP_RIGHT 7
#define OP_ADD 8
#define OP_MIN 9
const int M = 100;
const int B = 2000;
const int one = 1;
const int mask = 2;
int n,k;
void add_op(int tp,int t,int x,int y = -1);
void append_min(int ans,int a,int b){
int flag = 5;
add_op(OP_NOT,flag,a);
add_op(OP_AND,flag,mask,flag);
add_op(OP_ADD,flag,b,flag);
add_op(OP_ADD,flag,one,flag);
add_op(OP_RIGHT,flag,flag,k);
add_op(OP_AND,flag,one,flag);
for(int j = 1;j<k;j<<=1){
int tmp = 6;
add_op(OP_LEFT,tmp,flag,j);
add_op(OP_OR,flag,tmp,flag);
}
int rflag = 6;
add_op(OP_NOT,rflag,flag);
add_op(OP_AND,b,rflag,b);
add_op(OP_AND,a,flag,a);
add_op(OP_OR,ans,a,b);
return;
}
void add_op(int tp,int t,int x,int y){
if(tp == OP_MOVE)append_move(t,x);
else if(tp == OP_AND)append_and(t,x,y);
else if(tp == OP_OR)append_or(t,x,y);
else if(tp == OP_XOR)append_xor(t,x,y);
else if(tp == OP_NOT)append_not(t,x);
else if(tp == OP_LEFT)append_left(t,x,y);
else if(tp == OP_RIGHT)append_right(t,x,y);
else if(tp == OP_ADD)append_add(t,x,y);
else if(tp == OP_MIN)append_min(t,x,y);
return;
}
void construct_instructions(int s, int nn, int kk, int q) {
n = nn,k = kk;
vector<bool> v(B,0);
v[0] = 1;
append_store(one,v);
int ans = 3;
for(int i = 0;i<k;i++)v[i] = 1;
append_store(ans,v);
append_store(mask,v);
add_op(OP_MOVE,ans,0,ans);
add_op(OP_AND,ans,mask,ans);
for(int i = 1;i<n;i++){
int b = 4;
add_op(OP_RIGHT,b,0,i*k);
add_op(OP_AND,b,mask,b);
add_op(OP_MIN,ans,ans,b);
}
add_op(OP_MOVE,0,ans);
return;
}
# |
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 |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |