Submission #794006

# Submission time Handle Problem Language Result Execution time Memory
794006 2023-07-26T08:39:03 Z finn__ Bit Shift Registers (IOI21_registers) C++17
21 / 100
1 ms 304 KB
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;

void construct_instructions(int s, int n, int k, int q)
{
    // Store a in r0 and b in r1
    vector<bool> bits(2000);
    for (size_t i = 0; i < k; ++i)
        bits[i] = 1;
    append_store(11, bits);
    append_move(1, 0);
    append_and(1, 1, 11);
    append_right(0, 0, k);

    if (k == 1)
    {
        append_and(0, 0, 1);
    }
    else
    {
        append_or(2, 0, 1);    // r2 = a or b
        append_xor(3, 0, 1);   // r3 = a xor b
        append_and(2, 2, 3);   // r2 = (a or b) and (a xor b)
        append_right(3, 2, 1); // r3 = (a or b) and (a xor b) right shifted by 1
        append_and(2, 2, 3);   // r2 = first criterion to add 1

        append_right(4, 0, 1);
        append_and(4, 4, 1);
        append_right(5, 1, 1);
        append_and(5, 5, 0);
        append_or(4, 4, 5); // r4 = second criterion to add 1

        append_and(2, 2, 4); // r2 = the stuff to be added
        append_and(0, 1, 0);
        append_add(0, 0, 2);
    }
}

Compilation message

registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:9:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |     for (size_t i = 0; i < k; ++i)
      |                        ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# 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 Incorrect min value
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Incorrect min value
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Incorrect sorting
2 Halted 0 ms 0 KB -