#include "registers.h"
#include <bits/stdc++.h>
#define LEN 2000
#define INPUT 0
#define MASK 1
#define TOO_BIG 2
#define REMOVE_MASK 3
#define ONE 4
#define NOT_REMOVE 5
#define FINAL_SHIFT 8
#define ZERO 9
#define ALL 10
#define FIRST 12
#define SECOND 13
#define MASK_FIRST 14
#define MASK_SECOND 15
#define MAGIC 16
using namespace std;
void construct_instructions(int s, int n, int k, int q) {
vector<bool> first(LEN);
vector<bool> second(LEN);
for (int i = 0; i < n; i += 1)
{
for (int j = i * k; j < (i + 1) * k; j++)
{
(i % 2 ? second : first)[j] = true;
}
}
vector<bool> all(2000);
for (int i = 0; i < n * k; i++)
{
all[i] = true;
}
append_store(ALL, all);
append_store(MASK_FIRST, first);
append_store(MASK_SECOND, second);
vector<bool> one(LEN);
one[0] = true;
append_store(ONE, one);
vector<bool> too_big(LEN);
too_big[n * k] = true;
append_store(TOO_BIG, too_big);
vector<bool> mask(LEN);
for (int i = 0; i < n; i++)
{
mask[i * k + k - 1] = true;
}
append_store(MASK, mask);
vector<bool> magic(LEN);
magic[0] = true;
for (int i = n * k; i < LEN; i++)
{
magic[i] = true;
}
append_store(MAGIC, magic);
if (s == 0) {
for (int bit = 0; bit < k - 1; bit++)
{
if (bit) append_right(MASK, MASK, 1);
append_and(TOO_BIG, INPUT, MASK);
append_right(TOO_BIG, TOO_BIG, k - 1 - bit);
append_print(TOO_BIG);
append_and(FIRST, TOO_BIG, MASK_FIRST);
append_and(SECOND, TOO_BIG, MASK_SECOND);
append_add(FIRST, FIRST, MASK_FIRST);
append_add(SECOND, SECOND, MASK_SECOND);
append_and(FIRST, FIRST, MASK_FIRST);
append_and(SECOND, SECOND, MASK_SECOND);
append_or(REMOVE_MASK, FIRST, SECOND);
append_not(REMOVE_MASK, REMOVE_MASK);
append_and(REMOVE_MASK, REMOVE_MASK, ALL);
append_print(REMOVE_MASK);
append_add(NOT_REMOVE, REMOVE_MASK, MAGIC);
append_right(NOT_REMOVE, NOT_REMOVE, n * k);
append_print(NOT_REMOVE);
append_and(REMOVE_MASK, REMOVE_MASK, NOT_REMOVE);
append_print(REMOVE_MASK);
append_or(INPUT, INPUT, REMOVE_MASK);
}
vector<bool> zero(LEN);
for (int i = 0; i < n * k; i++)
{
zero[i] = true;
}
append_not(INPUT, INPUT);
append_store(ZERO, zero);
append_and(INPUT, INPUT, ZERO);
append_move(FINAL_SHIFT, INPUT);
for (int i = 1; i <= n; i <<= 1)
{
append_right(FINAL_SHIFT, FINAL_SHIFT, k * i);
append_or(INPUT, INPUT, FINAL_SHIFT);
append_move(FINAL_SHIFT, INPUT);
}
append_not(INPUT, INPUT);
}
if (s == 1) {
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Wrong answer detected in grader |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
228 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
228 KB |
Incorrect sorting |
2 |
Halted |
0 ms |
0 KB |
- |