Submission #668395

# Submission time Handle Problem Language Result Execution time Memory
668395 2022-12-03T19:40:21 Z finn__ cmp (balkan11_cmp) C++17
Compilation error
0 ms 0 KB
#include "cmp.h"

size_t y[6] = {
    1,
    4097,
    5121,
    5377,
    5441,
    5457};

void remember(int n)
{
    for (size_t i = 0; i < 6; i++)
        bit_set((n >> (2 * i)) + y[i]);
}

int compare(int b)
{
    size_t u = 0, v = 5;
    while (u < v)
    {
        size_t m = (u + v + 1) / 2;
        if (bit_get(b >> (2 * m)))
            u = m;
        else
            v = m - 1;
    }

    if (!((b >> (2 * (u - 1))) & 3))
        return -1;
    if (((b >> (2 * (u - 1))) & 3) == 3)
        return 1;
    if (((b >> (2 * (u - 1))) & 3) == 1)
        return bit_get(4 * (b >> (2 * u))) ? 1 : -1;
    return bit_get(4 * (b >> (2 * u)) + 3) ? -1 : 1;
}

Compilation message

cmp.cpp:3:1: error: 'size_t' does not name a type
    3 | size_t y[6] = {
      | ^~~~~~
cmp.cpp:2:1: note: 'size_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
    1 | #include "cmp.h"
  +++ |+#include <cstddef>
    2 | 
cmp.cpp: In function 'void remember(int)':
cmp.cpp:13:10: error: 'size_t' was not declared in this scope
   13 |     for (size_t i = 0; i < 6; i++)
      |          ^~~~~~
cmp.cpp:13:10: note: 'size_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
cmp.cpp:13:24: error: 'i' was not declared in this scope
   13 |     for (size_t i = 0; i < 6; i++)
      |                        ^
cmp.cpp:14:34: error: 'y' was not declared in this scope
   14 |         bit_set((n >> (2 * i)) + y[i]);
      |                                  ^
cmp.cpp: In function 'int compare(int)':
cmp.cpp:19:5: error: 'size_t' was not declared in this scope
   19 |     size_t u = 0, v = 5;
      |     ^~~~~~
cmp.cpp:19:5: note: 'size_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
cmp.cpp:20:12: error: 'u' was not declared in this scope
   20 |     while (u < v)
      |            ^
cmp.cpp:20:16: error: 'v' was not declared in this scope
   20 |     while (u < v)
      |                ^
cmp.cpp:22:15: error: expected ';' before 'm'
   22 |         size_t m = (u + v + 1) / 2;
      |               ^~
      |               ;
cmp.cpp:23:31: error: 'm' was not declared in this scope
   23 |         if (bit_get(b >> (2 * m)))
      |                               ^
cmp.cpp:29:23: error: 'u' was not declared in this scope
   29 |     if (!((b >> (2 * (u - 1))) & 3))
      |                       ^
cmp.cpp:31:22: error: 'u' was not declared in this scope
   31 |     if (((b >> (2 * (u - 1))) & 3) == 3)
      |                      ^
cmp.cpp:33:22: error: 'u' was not declared in this scope
   33 |     if (((b >> (2 * (u - 1))) & 3) == 1)
      |                      ^
cmp.cpp:35:35: error: 'u' was not declared in this scope
   35 |     return bit_get(4 * (b >> (2 * u)) + 3) ? -1 : 1;
      |                                   ^