Submission #797305

# Submission time Handle Problem Language Result Execution time Memory
797305 2023-07-29T09:02:04 Z caganyanmaz Bit Shift Registers (IOI21_registers) C++17
58 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define pb push_back
#include "registers.h"
using namespace std;

constexpr static int b = 2000;
vector<bool> v(b);
int n, s, k, q;

void fill_right(int i, int c, int tmp);

void expand_numbers()
{
        for (int i = 0; i < b; i++)
                v[i] = (i % (2*k)) < k;
        append_store(99, v);
        append_left(1, 0, (n-1 + (n&1)) * k);
        append_or(0, 0, 1);
        append_and(0, 0, 99);
}

void find_minimum()
{
        expand_numbers();
        for (int i = 0; i < b; i++)
                v[i] = !(i%k);
        const int ONES = 9;
        append_store(ONES, v);
        const int ELEVES = 10;
        for (int i = 0; i < b; i++)
                v[i] = (i%(2*k)) == (k);
        append_store(ELEVES, v);
        while (n > 1)
        {
                int step = n / 2;
                append_right(1, 0, step * k*2);
                append_not(2, 1);
                append_add(2, 2, ONES); // 2 is negative 1 right now
                append_print(2);
                append_print(0);
                append_add(2, 0, 2);
                append_and(2, 2, ELEVES);
                //append_print(2);
                fill_right(2, k, 3);
                append_not(3, 2);
                // 2 means 1 is bigger, 3 means 0 is bigger
                append_and(1, 1, 2);
                append_and(0, 0, 3);
                append_or(0, 0, 1);
                n -= step;
        }
}

void construct_instructions(int ss, int nn, int kk, int qq)
{
        s = ss, n = nn, k = kk, q = qq;
        if (s == 0)
                find_minimum();
}



void fill_right(int i, int c, int tmp)
{
        c++;
        while (c > 1)
        {
                if (c&1)
                {
                        c--;
                        append_right(tmp, i, 1);
                }
                else
                {
                        c >>= 1;
                        append_right(tmp, i, c);
                }
                append_or(i, i, tmp);
        }
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -