#include <bits/stdc++.h>
#define pb push_back
#include "registers.h"
using namespace std;
constexpr static int b = 2000;
vector<bool> v(b);
int n, s, k, q;
void fill_right(int i, int c, int tmp);
void expand_numbers()
{
for (int i = 0; i < n; i++)
for (int j = 0; j < k; j++)
v[i*k+j] = !(i&1);
append_store(99, v);
append_move(1, 0);
append_and(0, 0, 99);
append_not(99, 99);
append_and(1, 1, 99);
append_left(1, 1, (n-1 + (n&1)) * k);
append_or(0, 0, 1);
}
void find_minimum()
{
if (k == 1)
{
while (n>1)
{
if (n&1)
{
n--;
append_right(1, 0, 1);
}
else
{
n >>= 1;
append_right(1, 0, n);
}
append_and(0, 0, 1);
}
return;
}
expand_numbers();
for (int i = 0; i < b; i++)
v[i] = !(i%k);
const int ONES = 9;
append_store(ONES, v);
const int ELEVES = 10;
const int NELEVES = 11;
for (int i = 0; i < b; i++)
v[i] = (i%(2*k)) == (k);
append_store(ELEVES, v);
append_not(NELEVES, ELEVES);
while (n > 1)
{
int step = n / 2;
append_right(1, 0, step * k*2);
append_not(2, 1);
append_add(2, 2, ONES); // 2 is negative 1 right now
append_print(2);
append_print(0);
append_add(2, 0, 2);
append_and(2, 2, ELEVES);
append_print(2);
fill_right(2, k, 3);
append_and(2, 2, NELEVES);
append_not(3, 2);
// 2 means 1 is bigger, 3 means 0 is bigger
append_and(1, 1, 2);
append_and(0, 0, 3);
append_or(0, 0, 1);
n -= step;
}
}
void construct_instructions(int ss, int nn, int kk, int qq)
{
s = ss, n = nn, k = kk, q = qq;
if (s == 0)
find_minimum();
}
void fill_right(int i, int c, int tmp)
{
c++;
while (c > 1)
{
if (c&1)
{
c--;
append_right(tmp, i, 1);
}
else
{
c >>= 1;
append_right(tmp, i, c);
}
append_or(i, i, tmp);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |