Submission #438858

# Submission time Handle Problem Language Result Execution time Memory
438858 2021-06-28T19:15:58 Z Tc14 Bit Shift Registers (IOI21_registers) C++17
64 / 100
3 ms 620 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "registers.h"
using namespace std;
#define ve vector
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 10;

int m = 100;
int b = 2000;

void construct_instructions(int s, int n, int k, int q) {

    ve<bool> mask1(b), mask2(b), mask3(b);
    for (int i = 0; i < n / 2; i++) {
        for (int j = 0; j < k; j++) {
            mask1[2 * i * k + j] = true;
            mask2[2 * i * k + k + j] = true;
        }
    }
    for (int i = 0; i < k; i++) {
        mask3[i] = true;
    }

    append_store(1, mask1);
    append_store(2, mask2);
    append_store(11, mask3);

    ve<bool> end(b);
    for (int i = 0; i < k; i++) {
        end[n * k + i] = true;
    }
    append_store(13, end);
    append_or(0, 0, 13);

    for (int i = 0; i < n; i++) {

        if (i % 2) {
            append_and(12, 0, 11);
            append_right(0, 0, k);
        }

        // A
        append_and(3, 0, 1);

        // B
        append_and(4, 0, 2);

        // Subtract
        append_right(5, 4, k);
        append_xor(5, 5, 1);
        append_add(5, 5, 3);

        // Duplicate bits
        append_and(5, 5, 2);
        for (int i = 0; i < k - 1; i++) {
            append_left(6, 5, 1);
            append_or(5, 5, 6);
        }

        append_right(6, 5, k);
        append_or(5, 5, 6);

        // Negated mask
        append_not(7, 5);

        // Swap A
        append_left(8, 3, k);
        append_and(8, 8, 5);

        // Swap B
        append_right(9, 4, k);
        append_and(9, 9, 5);

        // No swap
        append_and(10, 0, 7);

        // Result
        append_or(10, 10, 8);
        append_or(10, 10, 9);

        if (i % 2) {
            append_left(10, 10, k);
            append_or(10, 10, 12);
        }

        append_move(0, 10);
    }

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer detected in grader
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 3 ms 620 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 2 ms 588 KB Output is correct