#include "registers.h"
#include <iostream>
using namespace std;
/*
negative(B) = NOT(B) + 1
A - B = A + negative(B)
sign(A-B) = (A - B) >> b-1
abs(A - B) = {tmp = negative(sign(A - B)); return (A + tmp) ^ tmp}
max(A, A) = A + B + abs(A - B)
tmp = negative(sign(A-B))
A = 00000100 = 4
B = 00001010 = 10
A-B = -(00000110)
= 11111001
sign(A-B) = 00000001
tmp = -sign(A-B) = 11111111
-sign(00000001) = 11111111
-sign(00000000) = 00000000
abs(x) = (x + tmp) ^ tmp
sign(x) = x >> b-1
negative(x) = NOT(x) + 1
A - B = A + negative(B)
tmp = negative(sign(A-B))
abs(A - B) = ((A-B) + tmp) ^ tmp;
max(A, B) = A + B + abs(A - B)
min(A, B) = A ^ B ^ max(A, B)
*/
const int b = 2000;
const int m = 100;
void solve12(int n, int k)
{
int A = 0;
// cerr << "A -> ";
append_print(A);
int B = 1;
append_right(B, A, k);
// cerr << "B -> ";
append_print(B);
vector<bool> v(b, 1);
for(int i = k; i < 2*k; i++)
v[i] = 0;
int clearnum2 = 2;
append_store(clearnum2, v);
// cerr << "clearnum2 -> ";
append_print(clearnum2);
append_and(A, A, clearnum2);
// cerr << "A -> ";
append_print(A);
int one = 3;
vector<bool> v2(b, 0);
v2[0] = 1;
append_store(one, v2);
int not_B = 4;
append_not(not_B, B);
int negative_B = 5;
append_add(negative_B, not_B, one);
int A_minus_B = 6;
append_add(A_minus_B, A, negative_B);
int sign_A_minus_B = 7;
append_right(sign_A_minus_B, A_minus_B, b-1);
int not_sign_A_minus_B = 8;
append_not(not_sign_A_minus_B, sign_A_minus_B);
int tmp = 9;
append_add(tmp, not_sign_A_minus_B, one);
int A_minus_B_plus_tmp = 10;
append_add(A_minus_B_plus_tmp, A_minus_B, tmp);
int abs_A_minus_B = 11;
append_xor(abs_A_minus_B, A_minus_B_plus_tmp, tmp);
int A_plus_B = 12;
append_add(A_plus_B, A, B);
int max_A_B_x2 = 13;
append_add(max_A_B_x2, A_plus_B, abs_A_minus_B);
int max_A_B = 14;
append_right(max_A_B, max_A_B_x2, 1);
int A_xor_B = 15;
append_xor(A_xor_B, A, B);
int min_A_B = 16;
append_xor(min_A_B, A_xor_B, max_A_B);
append_print(min_A_B);
int res = 0;
append_move(res, min_A_B);
}
//op, numbers, len of number, queries
//s == 0, n == 2
void construct_instructions(int s, int n, int k, int q)
{
if(s == 0 && n == 2 && k <= 2) solve12(n, k);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Incorrect min value |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |