Submission #612326

# Submission time Handle Problem Language Result Execution time Memory
612326 2022-07-29T13:06:42 Z dxz05 Bit Shift Registers (IOI21_registers) C++17
10 / 100
2 ms 632 KB
#include "registers.h"
#include <bits/stdc++.h>

using namespace std;

const int b = 2000, m = 100;

void construct_instructions(int s, int n, int k, int q) {
    int nxt = 2;

    function<int(int)> get_value = [&](int i) {
        int a = nxt++;
        assert(a < m);
        append_left(a, 0, b - (i + 1) * k);
        append_right(a, a, b - k);
        return a;
    };

    function<int(int, int)> pos = [&](int x, int i){
        int a = nxt++;
        assert(a < m);
        append_left(a, x, b - 1 - i);
        append_right(a, a, b - 1);
        return a;
    };

    function<int(int, int, int)> smaller = [&](int x, int y, int i){
        int a = nxt++;
        assert(a < m);
        append_not(a, pos(x, i));
        append_and(a, a, pos(y, i));
        return a;
    };

    function<int(int, int)> get_min = [&](int x, int y) {
        vector<int> v(k);
        v[k - 1] = nxt++;
        assert(v[k - 1] < m);

        append_store(v[k - 1], vector<bool>(b, 0));

        for (int i = k - 2; i >= 0; i--){
            int a = nxt++;
            append_xor(a, pos(x, i + 1), pos(y, i + 1));
            append_not(a, a);
            if (i < k - 2) append_and(a, v[i + 1], a);
            v[i] = a;
        }

        int a = nxt++;
        assert(a < m);

        append_store(a, vector<bool>(b, 0));
        for (int i = k - 1; i >= 0; i--) {
            int j = smaller(x, y, i);
            if (i < k - 1){
                append_and(v[i], j, v[i]);
            } else {
                append_or(v[i], j, v[i]);
            }
            append_or(a, a, v[i]);
        }
        
        return a;
    };

    function<int(int, int)> find_min = [&](int x, int y){
        int zx = get_min(x, y);
        int zy = nxt++;

        assert(zy < m);

        append_not(zy, zx);

        int val = nxt++;
        assert(val < m);
        
        append_store(val, vector<bool>(b, 0));
        for (int i = 0; i < k; i++){
            int a = nxt++;
            append_and(a, pos(x, i), zx);
            append_left(a, a, i);
            append_add(val, val, a);

            append_and(a, pos(y, i), zy);
            append_left(a, a, i);
            append_add(val, val, a);
        }        

        return val;        
    };

    nxt = 2;
    int x = find_min(get_value(0), get_value(1));
    append_move(1, x);

    for (int i = 2; i < n; i++){
        nxt = 2;
        x = find_min(1, get_value(i));
        append_print(x);
        append_move(1, x);
    }

    append_move(0, 1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Incorrect 1 ms 592 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Incorrect sorting
2 Halted 0 ms 0 KB -