Submission #466565

# Submission time Handle Problem Language Result Execution time Memory
466565 2021-08-19T16:25:59 Z alexxela12345 Bit Shift Registers (IOI21_registers) C++17
0 / 100
1 ms 332 KB
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;

const int B = 2000;

void solve0(int n, int k, int q) {
    append_print(0);
    // make n a power of 2
    {
        vector<bool> adding(B);
        bool was = 0;
        while (n & (n - 1)) {
            for (int i = n * k; i < (n + 1) * k; i++) {
                adding[i] = 1;
            }
            was = 1;
            n++;
        }
        if (was) {
            append_store(1, adding);
            append_xor(0, 0, 1);
        }
    }
    {
        // 8th cell is 1
        vector<bool> one(B);
        one[0] = 1;
        append_store(8, one);
    }
    for (int len = 1; len < n; len *= 2) {
        // what single iteration does:
        // for i in range(0, n, 2 * len):
        //     chkmin(a[i], a[i + len])
        // after all iterations a[0] is min(a)
        vector<bool> mask_odd(B), mask_even(B);
        for (int i = 0; i < n; i += 2 * len) {
            for (int j = 0; j < k; j++) {
                mask_even[i * len * k + j] = 1;
                mask_odd[(i + 1) * len * k + j] = 1;
            }
        }
        append_store(1, mask_even);
        append_store(2, mask_odd);
        append_and(3, 0, 1);
        append_and(4, 0, 2);
        append_right(4, 4, len * 2);
        append_print(3);
        append_print(4);
        append_not(4, 4);
        append_add(5, 3, 4);
        append_not(4, 4);
        append_print(5);
        vector<bool> mask_ones(B);
        for (int i = 0; i < n; i += 2 * len) {
            mask_ones[(2 * i + 1) * len] = 1;
        }
        append_store(6, mask_ones);
        append_and(6, 6, 5);
        append_right(7, 6, len);
        append_not(7, 7);
        append_add(7, 7, 8);
        append_print(7);
        append_and(3, 3, 7);
        append_not(7, 7);
        append_and(4, 4, 7);
        append_print(3);
        append_print(4);
        append_xor(0, 3, 4);
    }
}

void construct_instructions(int s, int n, int k, int q) {
    if (s == 0) {
        solve0(n, k, q);
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Incorrect min value
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Incorrect min value
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Incorrect min value
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Incorrect sorting
2 Halted 0 ms 0 KB -