Submission #1050803

#TimeUsernameProblemLanguageResultExecution timeMemory
1050803BlagojDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "dungeons.h" using namespace std; #define ll long long #define inf 1e12 const int mxn = 1e5 + 10, LOG1 = 19, LOG2 = 27; // steps, pwr int n; vector<int> s, p, w, l; int go[mxn][LOG1][LOG2], lim[mxn][LOG1][LOG2]; ll gain[mxn][LOG1][LOG2]; void init(int _n, vector<int> _s, vector<int> _p, vector<int> _w, vector<int> _l) { n = _n, s = _s, p = _p, w = _w, l = _l; for (int pwr = 0; pwr < LOG2; pwr++) { for (int i = 0; i < n; i++) { if ((1LL << pwr) >= s[i]) { if (w[i] == n) go[i][0][pwr] = -1; else { go[i][0][pwr] = w[i]; gain[i][0][pwr] = s[i]; lim[i][0][pwr] = inf; } } else { if (l[i] == n) go[i][0][pwr] = -1; else { go[i][0][pwr] = l[i]; gain[i][0][pwr] = p[i]; lim[i][0][pwr] = s[i]; } } } } for (int steps = 1; steps < LOG1; steps++) { for (int pwr = 0; pwr < LOG2; pwr++) { for (int i = 0; i < n; i++) { int nxt = go[i][steps - 1][pwr]; if (go[i][steps - 1][pwr] == -1 || go[nxt][steps - 1][pwr] == -1) go[i][steps][pwr] = -1; else { go[i][steps][pwr] = go[nxt][steps - 1][pwr]; gain[i][steps][pwr] = gain[i][steps - 1][pwr] + gain[nxt][steps - 1][pwr]; lim[i][steps][pwr] = min(lim[i][steps - 1][pwr], lim[nxt][steps - 1][pwr] - gain[i][steps - 1][pwr]); } } } } } ll simulate(int x, int z) { ll ans = z; while (x != n) { ll pwr = log2(ans); for (int i = LOG1 - 1; i >= 0; i--) { if (go[x][i][pwr] == -1) continue; if (ans >= lim[x][i][pwr]) continue; ans += gain[x][i][pwr]; x = go[x][i][pwr]; } if (ans >= s[x]) { ans += s[x]; x = w[x]; } else { ans += p[x]; x = l[x]; } } return ans; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:7:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+12' to '2147483647' [-Woverflow]
    7 | #define inf 1e12
      |             ^~~~
dungeons.cpp:25:23: note: in expansion of macro 'inf'
   25 |      lim[i][0][pwr] = inf;
      |                       ^~~
dungeons.cpp:46:105: error: no matching function for call to 'min(int&, long long int)'
   46 |      lim[i][steps][pwr] = min(lim[i][steps - 1][pwr], lim[nxt][steps - 1][pwr] - gain[i][steps - 1][pwr]);
      |                                                                                                         ^
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:46:105: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   46 |      lim[i][steps][pwr] = min(lim[i][steps - 1][pwr], lim[nxt][steps - 1][pwr] - gain[i][steps - 1][pwr]);
      |                                                                                                         ^
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:46:105: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   46 |      lim[i][steps][pwr] = min(lim[i][steps - 1][pwr], lim[nxt][steps - 1][pwr] - gain[i][steps - 1][pwr]);
      |                                                                                                         ^
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:46:105: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |      lim[i][steps][pwr] = min(lim[i][steps - 1][pwr], lim[nxt][steps - 1][pwr] - gain[i][steps - 1][pwr]);
      |                                                                                                         ^
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:46:105: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |      lim[i][steps][pwr] = min(lim[i][steps - 1][pwr], lim[nxt][steps - 1][pwr] - gain[i][steps - 1][pwr]);
      |                                                                                                         ^