This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "registers.h"
/*const int B = 2000;*/
const int B = 60;
const int M = 100;
int k;
const int INT_ONE = 90;
const int BOOL_TRUE = 91;
const int BOOL_FALSE = 92;
/* REGISTERS [90, 98] ARE RESERVED FOR CONSTANTS */
void add_constants() {
vector<bool> ret;
ret = vector<bool>(B, 0);
ret[0] = 1;
append_store(INT_ONE, ret);
ret = vector<bool>(B, 1);
append_store(BOOL_TRUE, ret);
ret = vector<bool>(B, 0);
append_store(BOOL_FALSE, ret);
}
void append_store_one(int result, int i) {
vector<bool> ret(B, 0);
ret[i] = 1;
append_store(result, ret);
}
void append_min(int result, int reg1, int reg2) {
/* only first k bits */
append_move(result, BOOL_FALSE);
int pointer = 80;
append_store_one(pointer, k-1);
append_move(85, BOOL_TRUE);
reprl(i, k-1, 0) {
append_and(81, reg1, pointer);
append_right(81, 81, i);
append_and(82, reg2, pointer);
append_right(82, 82, i);
append_xor(86, 81, 82);
append_add(86, 86, BOOL_TRUE);
append_add(81, 81, BOOL_TRUE);
append_add(82, 82, BOOL_TRUE);
append_and(81, reg1, 81);
append_and(82, reg2, 82);
append_or(84, 81, 82);
append_and(84, 84, 85);
append_or(result, result, 84);
append_right(pointer, pointer, 1);
append_and(85, 85, 86);
if (i == 0) {
append_and(85, 85, reg1);
append_or(result, result, 85);
} else {
append_not(87, 85);
append_and(result, result, 87);
}
}
}
void construct_instructions(int s, int n, int k_arg, int q) {k = k_arg;
assert(s == 0 && n == 2 && k <= 2);
if (k == 1) {
append_move(1, 0);
append_right(1, 1, 1);
append_and(0, 0, 1);
} else {
add_constants();
append_move(1, 0);
append_right(1, 1, 2);
append_min(2, 0, 1);
append_move(0, 2);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |