제출 #726944

#제출 시각아이디문제언어결과실행 시간메모리
726944pls33던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#ifndef _AAAAAAAAA
#include "dungeons.h"
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma region dalykai
template <typename F>
void _debug(F f)
{
    f();
}

#ifndef _AAAAAAAAA
#define debug(x)
#else
#define debug(x) _debug(x)
#endif
using p32 = pair<int, int>;
using p32u = pair<uint32_t, uint32_t>;
using p64 = pair<int64_t, int64_t>;
using p64u = pair<uint64_t, uint64_t>;
using vi16 = vector<int16_t>;
using vi16u = vector<uint16_t>;
using vi32 = vector<int>;
using vi32u = vector<uint32_t>;
using vi64 = vector<int64_t>;
using vi64u = vector<uint64_t>;
using vp32 = vector<p32>;
using vp32u = vector<p32u>;
using vp64 = vector<p64>;
using vp64u = vector<p64u>;
using vvi32 = vector<vi32>;
using vvi32u = vector<vi32u>;
using vvi64 = vector<vi64>;
using vvi64u = vector<vi64u>;
using vvp32 = vector<vp32>;
using vvp32u = vector<vp32u>;
using vvp64 = vector<vp64>;
using vvp64u = vector<vp64u>;
using f80 = long double;
#pragma endregion

struct dungeon_t
{
    int gain_win;
    int gain_lose;
    int win;
    int lose;
};

vector<dungeon_t> dungeon;

void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l)
{
    for (int i = 0; i < n; i++)
    {
        dungeon.emplace_back(s[i], p[i], w[i], l[i]);
    }

    return;
}

long long simulate(int x, int z)
{
    int64_t strength = z;

    for (int i = x; i < (int)dungeon.size();)
    {
        if (strength >= dungeon[i].gain_win)
        {
            strength += dungeon[i].gain_win;
            i = dungeon[i].win;
        }
        else
        {
            strength += dungeon[i].gain_lose;
            i = dungeon[i].lose;
        }
    }

    return strength;
}

#ifdef _AAAAAAAAA
int main()
{
    freopen("pozemiai.in", "r", stdin);
#ifndef __linux__
    atexit([]()
           {
        freopen("con", "r", stdin);
        system("pause"); });
#endif

    int n, q;
    std::vector<int> s, p, z;
    std::vector<int> w, l, x;
    std::vector<long long> answer;

    assert(scanf("%d %d", &n, &q) == 2);
    s.resize(n);
    p.resize(n);
    w.resize(n);
    l.resize(n);
    x.resize(q);
    z.resize(q);
    answer.resize(q);

    for (int i = 0; i < n; i++)
    {
        assert(scanf("%d", &s[i]) == 1);
    }
    for (int i = 0; i < n; i++)
    {
        assert(scanf("%d", &p[i]) == 1);
    }
    for (int i = 0; i < n; i++)
    {
        assert(scanf("%d", &w[i]) == 1);
    }
    for (int i = 0; i < n; i++)
    {
        assert(scanf("%d", &l[i]) == 1);
    }

    init(n, s, p, w, l);

    for (int i = 0; i < q; i++)
    {
        assert(scanf("%d %d", &x[i], &z[i]) == 2);
        answer[i] = simulate(x[i], z[i]);
    }

    for (int i = 0; i < q; i++)
    {
        printf("%lld\n", answer[i]);
    }

    return 0;
}
#endif

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

dungeons.cpp:12: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
   12 | #pragma region dalykai
      | 
dungeons.cpp:47: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   47 | #pragma endregion
      | 
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/vector:64,
                 from dungeons.h:1,
                 from dungeons.cpp:2:
/usr/include/c++/10/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = dungeon_t; _Args = {int&, int&, int&, int&}; _Tp = dungeon_t]':
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = dungeon_t; _Args = {int&, int&, int&, int&}; _Tp = dungeon_t; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<dungeon_t>]'
/usr/include/c++/10/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int&, int&}; _Tp = dungeon_t; _Alloc = std::allocator<dungeon_t>; std::vector<_Tp, _Alloc>::reference = dungeon_t&]'
dungeons.cpp:63:52:   required from here
/usr/include/c++/10/ext/new_allocator.h:150:4: error: new initializer expression list treated as compound expression [-fpermissive]
  150 |  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/ext/new_allocator.h:150:4: error: no matching function for call to 'dungeon_t::dungeon_t(int&)'
dungeons.cpp:49:8: note: candidate: 'dungeon_t::dungeon_t()'
   49 | struct dungeon_t
      |        ^~~~~~~~~
dungeons.cpp:49:8: note:   candidate expects 0 arguments, 1 provided
dungeons.cpp:49:8: note: candidate: 'constexpr dungeon_t::dungeon_t(const dungeon_t&)'
dungeons.cpp:49:8: note:   no known conversion for argument 1 from 'int' to 'const dungeon_t&'
dungeons.cpp:49:8: note: candidate: 'constexpr dungeon_t::dungeon_t(dungeon_t&&)'
dungeons.cpp:49:8: note:   no known conversion for argument 1 from 'int' to 'dungeon_t&&'