#include "registers.h"
#include <bits/stdc++.h>
using namespace std;
const int M = 100, B = 2000;
void keep_prefix(int x, int l)
{
append_left(x, x, B - l);
append_right(x, x, B - l);
}
void or_numbers(int n, int k, int t, int x)
{
/*
bit or n k-bit numbers stored at first k bits
x: array
10, 11: working space
12: empty filter
t: output
*/
append_move(10, x);
while (n > 1)
{
int m = (n + 1) / 2;
append_right(11, 10, m * k);
append_or(10, 11, 10);
n = m;
}
keep_prefix(10, k);
append_move(t, 10);
}
void construct_instructions(int s, int n, int k, int q)
{
/*
filter msb
0: array
1: every k bits only i-th has value
2: filter
3: filter helper
4: empty checker
5: stupid
6: full
-> 0: filtered array
*/
vector<bool> stupid(B, 0), full(B, 1), one(B, 0), kless1(B, 0), everyk(B, 0);
for (int i = 0; i < n * k; i++)
stupid[i] = 1;
one[0] = 1;
for (int i = 0; i < n * k; i++)
if(i % k != k - 1)
kless1[i] = 1;
else everyk[i] = 1;
append_store(5, stupid);
append_store(6, full);
append_store(7, one);
append_store(8, kless1);
append_store(9, everyk);
append_xor(0, 0, 5);
for (int i = k - 1; i >= 0; i--)
{
vector<bool> filter(B, 0);
for (int j = i; j < n * k; j += k)
filter[j] = 1;
append_store(1, filter);
append_and(2, 0, 1);
append_right(2, 2, i);
// if none of them has the bit, 4 stores all 1 and becomes all zero when added 1,
// thus append_not again and set the filter to all 1
append_not(4, 2);
append_add(4, 4, 7);
append_right(4, 4, B - 1);
append_add(4, 4, 6);
// using 111...110 to duplicate (but not-ed) first k-1 bits
append_add(3, 2, 8);
append_not(3, 3);
append_xor(2, 3, 9);
append_or(2, 4, 2);
append_and(0, 2, 0);
append_print(0);
}
or_numbers(n, k, 0, 0);
append_xor(0, 0, 5);
keep_prefix(0, k);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |