Submission #668647

#TimeUsernameProblemLanguageResultExecution timeMemory
668647finn__Coins (IOI17_coins)C++17
100 / 100
9 ms1556 KiB
#include "coins.h"

std::vector<int> coin_flips(std::vector<int> b, int c)
{
    unsigned const row = c / 8, col = c % 8;
    int u = row ^ 7, v = col ^ 7;

    for (unsigned i = 0; i < 8; i++)
    {
        for (unsigned j = 0; j < 8; j++)
        {
            int const &x = b[i * 8 + j];

            if (!(i & 4))
                u ^= (x << 2);
            if (!(i & 2))
                u ^= (x << 1);
            if (!(i & 1))
                u ^= x;

            if (!(j & 4))
                v ^= (x << 2);
            if (!(j & 2))
                v ^= (x << 1);
            if (!(j & 1))
                v ^= x;
        }
    }

    return {u * 8 + v};
}

int find_coin(std::vector<int> b)
{
    unsigned row = 0, col = 0;

    for (unsigned i = 0; i < 8; i++)
    {
        for (unsigned j = 0; j < 8; j++)
        {
            int const &x = b[i * 8 + j];

            if (!(i & 4))
                row ^= (x << 2);
            if (!(i & 2))
                row ^= (x << 1);
            if (!(i & 1))
                row ^= x;

            if (!(j & 4))
                col ^= (x << 2);
            if (!(j & 2))
                col ^= (x << 1);
            if (!(j & 1))
                col ^= x;
        }
    }

    return row * 8 + col;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...