Submission #612554

#TimeUsernameProblemLanguageResultExecution timeMemory
612554AmirElarbiDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 2e9+5
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9;
const int nax = 4e5+5;
const int lg = 20;
#include "dungeons.h"
int nxt[8][nax][lg], mn[8][nax][lg], n;
vi s,p,w,l;
ll sm[8][nax][lg];
void init(int N, vi S, vi P, vi W, vi L) {
    n = N; 
    s = S, p = P, w = W, l = L;
    s.pb(0), p.pb(0);
    for (int i = 0; i < lg; ++i)
    {
        for(int j =0; j < 8; j++) nxt[j][n][i] = n, sm[j][n][i] = 0, mn[j][n][i] = 1e8;
    }
    int cur = 1;
    for(int ind = 0; ind < 8; ind++){
        for (int i = 0; i < n; ++i)
        {
            if(cur >= s[i]) nxt[ind][i][0] = w[i], sm[ind][i][0] = s[i], mn[ind][i][0] = 1e8;
            else nxt[ind][i][0] = l[i], sm[ind][i][0] = p[i], mn[ind][i][0] =s[i];     
        }
        for (int j = 1; j < lg; ++j){
            for (int i = n-1; i >= 0; --i)
            {
                nxt[ind][i][j] = nxt[ind][nxt[ind][i][j-1]][j-1];
                sm[ind][i][j] = sm[ind][i][j-1] + sm[ind][nxt[ind][i][j-1]][j-1];
                mn[ind][i][j] = min(mn[ind][i][j-1], max(mn[ind][nxt[ind][i][j-1]][j-1] - sm[ind][i][j-1],0ll));
            }
        } 
        cur *= 10;
    }
}

long long simulate(int x, int z) {
    ll ind = 0, cur = 1, val = z;
    while(x != n){
        while(ind < 7 && 10*cur <= val) ind++, cur *= 10;
        for (int i = 0; i < lg; ++i)
        {
            if(min(val,(ll)(1e7)) < mn[ind][x][i]){
                val += sm[ind][x][i];
                x = nxt[ind][x][i];
            }
        }
        if(x == n) break;
        if(val >= s[x]) val += s[x], x = w[x];
        else val += p[x], x = l[x];   
    }
    return val;
}

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:50:111: error: no matching function for call to 'min(int&, const long long int&)'
   50 |                 mn[ind][i][j] = min(mn[ind][i][j-1], max(mn[ind][nxt[ind][i][j-1]][j-1] - sm[ind][i][j-1],0ll));
      |                                                                                                               ^
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:50:111: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   50 |                 mn[ind][i][j] = min(mn[ind][i][j-1], max(mn[ind][nxt[ind][i][j-1]][j-1] - sm[ind][i][j-1],0ll));
      |                                                                                                               ^
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:50:111: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   50 |                 mn[ind][i][j] = min(mn[ind][i][j-1], max(mn[ind][nxt[ind][i][j-1]][j-1] - sm[ind][i][j-1],0ll));
      |                                                                                                               ^
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:50:111: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   50 |                 mn[ind][i][j] = min(mn[ind][i][j-1], max(mn[ind][nxt[ind][i][j-1]][j-1] - sm[ind][i][j-1],0ll));
      |                                                                                                               ^
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:50:111: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   50 |                 mn[ind][i][j] = min(mn[ind][i][j-1], max(mn[ind][nxt[ind][i][j-1]][j-1] - sm[ind][i][j-1],0ll));
      |                                                                                                               ^