Submission #550899

#TimeUsernameProblemLanguageResultExecution timeMemory
550899topovikDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define s second #define pi acos(-1) using namespace std; typedef long long ll; typedef long double ld; const ll oo = 1e18; const ld eps = (ld)1 / oo; const ll N = 2e5 + 100; const ll MX = 1000; const ll M = 30; vector <vector <vector <pair<int, ll> > > > binpow; vector <ll> str; vector <int> s, p, w, l; int n; int mx = 0; void init(int n1, vector <int> s1, vector <int> p1, vector <int> w1, vector <int> l1) { n = n1; s = s1, p = p1, w = w1, l = l1; for (ll i = 0; i < n; i++) str.pb(s[i]); str.pb(0); sort(str.begin(), str.end()); str.resize(unique(str.begin(), str.end()) - str.begin()); str.resize(min(MX, str.size())); binpow.resize(str.size()); for (ll i = 0; i < str.size(); i++) { binpow[i].resize(n + 1); for (ll j = 0; j <= n; j++) binpow[i][j].resize(M); for (ll j = 0; j < n; j++) if (s[j] > str[i]) binpow[i][j][0] = {l[j], p[j]}; else binpow[i][j][0] = {w[j], s[j]}; binpow[i][n][0] = {n, 0}; for (ll c = 1; c < M; c++) { for (ll j = 0; j <= n; j++) { ll nx = binpow[i][j][c - 1].f; binpow[i][j][c].f = binpow[i][nx][c - 1].f; binpow[i][j][c].s = binpow[i][j][c - 1].s + binpow[i][nx][c - 1].s; } } } } ll simulate(int x, int y1) { ll y = y1; for (int i = 0; i < str.size(); i++) { if (y < str[i]) { for (int j = M - 1; j >= 0; j--) if (y + binpow[i - 1][x][j].s < str[i]) y += binpow[i - 1][x][j].s, x = binpow[i - 1][x][j].f; y += binpow[i - 1][x][0].s; x = binpow[i - 1][x][0].f; if (x == n) return y; } } while (x != n) { if (s[x] > y) { y += p[x]; x = l[x]; } else { y += s[x]; x = w[x]; } } return y; } //int main() //{ // srand(time(NULL)); // ll n, q; // cin >> n >> q; // vector <int> a(n), b(n), c(n), d(n); // for (ll i = 0; i < n; i++) cin >> a[i]; // for (ll i = 0; i < n; i++) cin >> b[i]; // for (ll i = 0; i < n; i++) cin >> c[i]; // for (ll i = 0; i < n; i++) cin >> d[i]; // init(n, a, b, c, d); // while (q--) // { // ll x, z; // cin >> x >> z; // cout << simulate(x, z) << endl; // } //} /* 1 4 -100000 -100000 100000 -100000 -100000 100000 -100000 -100000 100000 -100000 -100000 100000 -100000 -100000 100000 -100000 -100000 100000 -100000 -100000 100000 -100000 -100000 100000 */

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:34:34: error: no matching function for call to 'min(const ll&, std::vector<long long int>::size_type)'
   34 |     str.resize(min(MX, str.size()));
      |                                  ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
dungeons.cpp:34:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
   34 |     str.resize(min(MX, str.size()));
      |                                  ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
dungeons.cpp:34:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
   34 |     str.resize(min(MX, str.size()));
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
dungeons.cpp:34:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |     str.resize(min(MX, str.size()));
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
dungeons.cpp:34:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |     str.resize(min(MX, str.size()));
      |                                  ^
dungeons.cpp:36:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (ll i = 0; i < str.size(); i++)
      |                    ~~^~~~~~~~~~~~
dungeons.cpp: In function 'll simulate(int, int)':
dungeons.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < str.size(); i++)
      |                     ~~^~~~~~~~~~~~