Submission #1061801

# Submission time Handle Problem Language Result Execution time Memory
1061801 2024-08-16T13:38:03 Z j_vdd16 Bit Shift Registers (IOI21_registers) C++17
21 / 100
1 ms 348 KB
#include "registers.h"

#include <algorithm>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

//#define int long long
#define loop(X, N) for(int X = 0; X < (N); X++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

void spread(int i, int extra, int k) {
    int maxPow = 0;
    while (k) {
        k /= 2;
        maxPow++;
    }

    for (int pow = 1; pow <= maxPow; pow *= 2) {
        append_right(extra, i, pow);
        append_or(i, i, extra);
    }
}

void findMin(int reg, int step, int n, int k) {
    int pow = 1 << reg;

    append_left(reg + 1, reg, k * pow);

    append_and(reg + 1, reg + 1, 99);
    append_xor(reg + 2, reg, 1);

    //append_print(0);
    //append_print(1);
    //append_print(2);

    append_right(reg + 3, reg + 2, 1);
    spread(reg + 3, reg + 4, k); //8
    //append_print(3);
    //append_print(4);

    append_not(reg + 3, reg + 3);
    append_and(reg + 4, reg + 2, reg + 3);

    //append_print(4);

    append_and(reg + 5, reg + 0, reg + 4);
    spread(reg + 5, reg + 6, k); //8
    //append_print(5);

    append_and(reg + 2, reg + 5, 2);
    append_xor(reg, reg, 2);
    append_right(reg, reg, k);

    //append_print(0);

    append_print(reg);
}

void construct_instructions(int s, int n, int k, int q) {
    if (s == 1) return;
    
    vb even(2000, true);

    for (int i = 0; i < n; i++) {
        for (int j = i * k * 2; j < i * k * 2 + k; j++) {
            even[j] = false;
        }
    }
    //for (int i = k * n; i < 2000; i++) even[i] = false;
    append_store(99, even);

    findMin(0, 0, n, k);

    /*
    0 2 5 100
    22 19
    */
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Incorrect min value
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Incorrect min value
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -