제출 #1296411

#제출 시각아이디문제언어결과실행 시간메모리
1296411chikien2009Broken Device (JOI17_broken_device)C++20
컴파일 에러
0 ms0 KiB
#include "Annalib.h"

void SetBlock(int *pos, int a, int b, int c)
{
    (*pos) = a;
    (*(pos + 1)) = b;
    (*(pos + 2)) = c;
}

void Anna(int n, long long x, int k, int p[])
{
    int dead[n], bit[n];
    for (int i = 0, j = 0; i < n; ++i)
    {
        bit[i] = 0;
        if (j < k && i == p[j])
        {
            dead[i] = 1;
        }
        else
        {
            dead[i] = 0;
        }
    }
    for (int i = 0; i < n; i += 3)
    {
        if (dead[i] + dead[i + 1] + dead[i + 2] > 1)
        {
            continue;
        }
        else if (dead[i] + dead[i + 1] + dead[i + 2] == 0)
        {
            if (x % 4 == 0)
            {
                SetBlock(bit + i, 1, 0, 0);
            }
            if (x % 4 == 1)
            {
                SetBlock(bit + i, 1, 0, 1);
            }
            if (x % 4 == 2)
            {
                SetBlock(bit + i, 0, 1, 1);
            }
            if (x % 4 == 3)
            {
                SetBlock(bit + i, 1, 1, 1);
            }
            x >>= 2;
        }
        else if (dead[i] == 1)
        {
            if (x % 2 == 1)
            {
                SetBlock(bit + i, 0, 0, 1);
            }
            if (x % 2 == 0)
            {
                SetBlock(bit + i, 0, 1, 0);
            }
            x >>= 1;
        }
        else if (dead[i] == 1)
        {
            if (x % 4 == 0)
            {
                SetBlock(bit + i, 1, 0, 0);
                x >>= 2;
                continue;
            }
            if (x % 4 == 1)
            {
                SetBlock(bit + i, 1, 0, 1);
                x >>= 2;
                continue;
            }
            if (x % 2 == 1)
            {
                SetBlock(bit + i, 0, 0, 1);
                x >>= 1;
            }
        }
        else
        {
            if (x % 2 == 1)
            {
                SetBlock(bit + i, 0, 0, 1);
            }
            if (x % 2 == 0)
            {
                SetBlock(bit + i, 0, 1, 0);
            }
            x >>= 1;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        Set(i, bit[i]);
    }
}
#include "Brunolib.h"

long long Bruno(int n, int a[])
{
    vector<int> v;
    long long res = 0;
    for (int i = 0; i < n; i += 3)
    {
        if (a[i] == 0 && a[i + 1] == 0 && a[i + 2] == 0)
        {
            continue;
        }
        if ((a[i] == 0 && a[i + 1] == 0 && a[i + 2] == 1) || 
        (a[i] == 1 && a[i + 1] == 1 && a[i + 2] == 0))
        {
            v.push_back(1);
        }
        else if (a[i] == 0 && a[i + 1] == 1 && a[i + 2] == 0)
        {
            v.push_back(0);
        }
        else if (a[i] == 0)
        {
            v.push_back(0);
            v.push_back(1);
        }
        else
        {
            v.push_back(a[i + 2]);
            v.push_back(a[i + 1]);
        }
    }
    while (!v.empty() && v.back() == 0)
    {
        v.pop_back();
    }
    reverse(v.begin(), v.end());
    for (auto & i : v)
    {
        res <<= 1;
        res += i;
    }
    return res;
}

컴파일 시 표준 에러 (stderr) 메시지

# 2번째 컴파일 단계

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> v;
      |     ^~~~~~
Bruno.cpp:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> v;
      |            ^~~
Bruno.cpp:16:13: error: 'v' was not declared in this scope
   16 |             v.push_back(1);
      |             ^
Bruno.cpp:20:13: error: 'v' was not declared in this scope
   20 |             v.push_back(0);
      |             ^
Bruno.cpp:24:13: error: 'v' was not declared in this scope
   24 |             v.push_back(0);
      |             ^
Bruno.cpp:29:13: error: 'v' was not declared in this scope
   29 |             v.push_back(a[i + 2]);
      |             ^
Bruno.cpp:33:13: error: 'v' was not declared in this scope
   33 |     while (!v.empty() && v.back() == 0)
      |             ^
Bruno.cpp:37:13: error: 'v' was not declared in this scope
   37 |     reverse(v.begin(), v.end());
      |             ^
Bruno.cpp:37:5: error: 'reverse' was not declared in this scope
   37 |     reverse(v.begin(), v.end());
      |     ^~~~~~~