Submission #1042145

# Submission time Handle Problem Language Result Execution time Memory
1042145 2024-08-02T15:21:23 Z 0npata Dungeons Game (IOI21_dungeons) C++17
Compilation error
0 ms 0 KB
#include "dungeons.h"
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define vec vector

const int MXN = 50'050;
const int LOGN = 30;
const int LOGS = 30;

struct Data {
    int mnt;
    int sum;
    int32_t v;
};

Data binjmps[LOGS][MXN][LOGN];

int n;
vec<int> s;
vec<int> p;
vec<int32_t> w;
vec<int32_t> l;

const int MXS = 1e8+100;

void init(int32_t n_i, std::vector<int32_t> s_i, std::vector<int32_t> p_i, std::vector<int32_t> w_i, std::vector<int32_t> l_i) {
    // preprocessing fill in binjmps
    s =  s_i;
    s.push_back(0);
    p = p_i;
    w = w_i;
    w.push_back(n_i);
    l = l_i;
    n = n_i;

    for(int i = 0; i<LOGS; i++) {
        for(int j = 0; j<=n; j++) {
            if(s[j] > (1<<i)) {
                binjmps[i][j][0] = {s[j], p[j], l[j]};
            }
            else {
                binjmps[i][j][0] = {MXS, s[j], w[j]};
            }
        }
        for(int k = 1; k<LOGN; k++) {
            for(int j = 0; j<=n; j++) {
                auto nxt = &binjmps[i][binjmps[i][j][k-1].v][k-1];
                auto me = &binjmps[i][j][k-1];

                int nxt_mnt = (nxt->mnt == MXS) ? MXS : (nxt->mnt-min(me->sum, (int)nxt->mnt));
                binjmps[i][j][k] = {min(me->mnt, nxt_mnt), me->sum+nxt->sum, nxt->v};
                assert(binjmps[i][j][k].sum >= 0);
            }
        }
    }

	return;
}

long long simulate(int32_t u, int32_t z) {
    
    int cur_s = z;
    for(int32_t i = 0; i<LOGS; i++) {
        //cerr << u << ' ' << cur_s << '\n';
        for(int32_t j = LOGN-1; j>=0; j--) {
            if(binjmps[i][u][j].mnt > cur_s) {
                cur_s += binjmps[i][u][j].sum;
                u = binjmps[i][u][j].v;
            }
        }
    }

cerr << cur_s << '\n';
    return cur_s;
}

Compilation message

dungeons.cpp: In function 'void init(int32_t, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:30:10: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   30 |     s =  s_i;
      |          ^~~
In file included from /usr/include/c++/10/vector:72,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
dungeons.cpp:32:9: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   32 |     p = p_i;
      |         ^~~
In file included from /usr/include/c++/10/vector:72,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~