Submission #438379

# Submission time Handle Problem Language Result Execution time Memory
438379 2021-06-27T21:58:07 Z SHZhang Bit Shift Registers (IOI21_registers) C++17
33 / 100
4 ms 576 KB
#include "registers.h"
#include <vector>

using namespace std;

void construct_instructions(int s, int n, int k, int q) {
    (void)s; (void)q;
    vector<bool> ones_above;
    for (int i = 0; i < n * k; i++) ones_above.push_back(false);
    for (int i = n * k; i < 2000; i++) ones_above.push_back(true);
    if (n > 2) {
        append_store(1, ones_above);
        append_or(0, 0, 1);
    }

    vector<bool> all_0s;
    for (int i = 0; i < 2000; i++) all_0s.push_back(false);

    for (int i = k - 1; i >= 0; i--) {
        append_move(1, 0);
    	for (int j = 0; (1 << j) < n; j++) {
            append_right(2, 1, k * (1 << j));
            append_and(1, 1, 2);
        }

        vector<bool> bit_only = all_0s;
        bit_only[i] = true;
        append_store(2, bit_only);
        append_and(3, 1, 2);
        append_or(99, 3, 99);
        if (i) {
            append_not(3, 3);
            append_and(1, 2, 3);

            for (int j = 0; (1 << j) < n; j++) {
                append_left(2, 1, k * (1 << j));
                append_or(1, 1, 2);
            }
            append_and(1, 0, 1);
            if (k <= 2) {
                append_right(1, 1, 1);
                append_or(0, 0, 1);
            } else {
                append_store(4, all_0s);
                for (int j = 1; j < k; j++) {
                    append_right(2, 1, j);
                    vector<bool> mask = all_0s;
                    for (int x = 0; x < 2000; x++) {
                        if (x % k < k - j) mask[x] = true;
                    }
                    append_store(3, mask);
                    append_and(2, 2, 3);
                    append_or(4, 2, 4);
                }
                append_or(0, 0, 4);
            }
        }
        append_print(0);
    }

    append_move(0, 99);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 576 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 576 KB Incorrect sorting
2 Halted 0 ms 0 KB -