Submission #612036

# Submission time Handle Problem Language Result Execution time Memory
612036 2022-07-29T10:20:26 Z dxz05 Bit Shift Registers (IOI21_registers) C++17
10 / 100
1 ms 428 KB
#include "registers.h"
#include <bits/stdc++.h>

using namespace std;

const int b = 100, m = 2000;

int n, k;

void construct_instructions(int s, int _n, int _k, int q) {
    n = _n, k = _k;
    
    vector<vector<int>> pos(n, vector<int>(k, 0));
    int nxt = 1;

    for (int i = 0; i < n; i++){
        for (int j = 0; j < k; j++){
            pos[i][j] = nxt;
            append_left(nxt, 0, m - (i * k + j) - 1);
            append_right(nxt, nxt, m - 1);
            append_print(nxt);

            nxt++;
        }
    }

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

        int b = nxt++;
        append_and(b, a, pos[y][i]);
        return b;
    };

    function<int(int, int)> get_min = [&](int x, int y) {
        vector<int> v(k);
        v[k - 1] = nxt++;
        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++;
        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++;
        append_print(zx);

        append_not(zy, zx);
        append_print(zy);

        int val = nxt++;
        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;        
    };

    int x = 0;
    for (int i = 1; i < n; i++) x = find_min(x, i);
    append_print(x);

    append_move(0, x);
}
# 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 Runtime error 1 ms 428 KB Execution killed with signal 11
2 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 1 ms 212 KB Wrong answer detected in grader
2 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 -