제출 #1296412

#제출 시각아이디문제언어결과실행 시간메모리
1296412chikien2009Broken 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"
#include <bits/stdc++.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:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> v;
      |     ^~~~~~
Bruno.cpp:6:5: note: suggested alternatives:
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from Bruno.cpp:2:
/usr/include/c++/13/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
Bruno.cpp:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> v;
      |            ^~~
Bruno.cpp:17:13: error: 'v' was not declared in this scope
   17 |             v.push_back(1);
      |             ^
Bruno.cpp:21:13: error: 'v' was not declared in this scope
   21 |             v.push_back(0);
      |             ^
Bruno.cpp:25:13: error: 'v' was not declared in this scope
   25 |             v.push_back(0);
      |             ^
Bruno.cpp:30:13: error: 'v' was not declared in this scope
   30 |             v.push_back(a[i + 2]);
      |             ^
Bruno.cpp:34:13: error: 'v' was not declared in this scope
   34 |     while (!v.empty() && v.back() == 0)
      |             ^
Bruno.cpp:38:13: error: 'v' was not declared in this scope
   38 |     reverse(v.begin(), v.end());
      |             ^
Bruno.cpp:38:5: error: 'reverse' was not declared in this scope
   38 |     reverse(v.begin(), v.end());
      |     ^~~~~~~
Bruno.cpp:38:5: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:73,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:249:1: note:   'std::reverse'
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
In file included from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_algo.h:1292:33: note:   'std::ranges::reverse'
 1292 |   inline constexpr __reverse_fn reverse{};
      |                                 ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:89:
/usr/include/c++/13/ranges:4003:31: note:   'std::ranges::views::reverse'
 4003 |     inline constexpr _Reverse reverse;
      |                               ^~~~~~~