#include "registers.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<vvpii> vvvpii;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
void construct_instructions(int s, int n, int k, int q)
{
vb mask;
// mask for 1
mask.assign(2000, 0);
mask[0] = 1;
append_store(98, mask);
auto swap = [&](int a, int b, int filter)
{
// smaller stuff lands in a
append_not(2, a);
append_add(2, 2, 98);
append_add(2, 2, b); // b - a
{
append_xor(3, a, 2);
append_xor(3, b, 3);
append_and(95, 3, filter); // filters the carrybits we prepared with the xor
append_right(96, 95, k);
append_not(96, 96);
append_add(96, 96, 98);
append_add(94, 95, 96); // with filter - (filter >> k) we build filters with k bits
}
append_xor(2, a, b);
append_and(2, 2, 94);
append_xor(a, a, 2);
if (s == 1)
append_xor(b, b, 2);
};
if (s == 0)
{
mask.assign(2000, 0);
int next = 1;
while (next < n)
next *= 2;
fill(mask.begin() + n * k, mask.begin() + next * k, 1);
append_store(99, mask);
append_or(0, 0, 99);
while (next > 1)
{
append_right(1, 0, (next / 2) * k);
vb filter;
filter.assign(2000, 0);
for (int i = 0; i < next / 2; ++i)
filter[i * k + k] = 1;
append_store(97, filter);
swap(0, 1, 97);
next >>= 1;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
- |