Submission #524713

#TimeUsernameProblemLanguageResultExecution timeMemory
524713LoboDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include "dungeons.h"
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 55000

int N;
pair<int,int> nx[maxn][10][32];
vector<int> st;

pair<int,int> nxt(int u, int qtd, int id) {
    int val = 0;
    for(int pt = 30; pt >= 0; pt--) {
        if(qtd >= (1<<pt)) {
            qtd-= (1<<pt);
            val+= nx[u][id][pt].sc;
            u = nx[u][id][pt].fr;
        }
    }

    return mp(u,val);
}

int32_t simulate(int32_t x, int32_t z) {
    int ans = 0;
    int id = 0;
    while(z >= st[id]) id++;
    id--;

    int cnt = 0;
    while(x != N && ++cnt < 10) {
        int l = 0;
        int r = 1e2 + 10;
        pair<int,int> ans1;
        while(l <= r) {
            int mid = (l+r)>>1;

            auto aux = nxt(x,mid,id);
            if(z+aux.sc >= st[id+1] || aux.fr == N) {
                ans1 = aux;
                ans1.sc+= z;
                r = mid-1;
            }
            else {
                l = mid+1;
            }
        }

        x = ans1.fr;
        z = ans1.sc;
        id++;
    }

    return z;
}

void init(int32_t n, vector<int32_t> s, vector<int32_t> p, vector<int32_t> w, vector<int32_t>32_t l) {
    N = n;
    st.pb(0);
    st.pb(inf);
    for(int i = 0; i < n; i++) {
        st.pb(s[i]);
    }
    sort(all(st));
    st.erase(unique(all(st)),st.end());


    for(int i = 0; i < st.size(); i++) {
        for(int j = 0; j < n; j++) {
            if(s[j] <= st[i]) {
                nx[j][i][0] = mp(w[j],s[j]);
            }
            else {
                nx[j][i][0] = mp(l[j],p[j]);

            }
        }

        for(int pt = 0; pt <= 30; pt++) {
            nx[n][i][pt].fr = n;
            nx[n][i][pt].sc = 0; 
        }
        for(int pt = 1; pt <= 30; pt++) {
            for(int j = 0; j < n; j++) {
                nx[j][i][pt].fr = nx[nx[j][i][pt-1].fr][i][pt-1].fr;
                nx[j][i][pt].sc = nx[j][i][pt-1].sc + nx[nx[j][i][pt-1].fr][i][pt-1].sc;
            }
        }
    }
}

Compilation message (stderr)

dungeons.cpp:35:9: error: ambiguating new declaration of 'int32_t simulate(int32_t, int32_t)'
   35 | int32_t simulate(int32_t x, int32_t z) {
      |         ^~~~~~~~
In file included from dungeons.cpp:1:
dungeons.h:4:11: note: old declaration 'long long int simulate(int, int)'
    4 | long long simulate(int x, int z);
      |           ^~~~~~~~
dungeons.cpp: In function 'int32_t simulate(int32_t, int32_t)':
dungeons.cpp:36:9: warning: unused variable 'ans' [-Wunused-variable]
   36 |     int ans = 0;
      |         ^~~
dungeons.cpp: At global scope:
dungeons.cpp:68:94: error: expected ',' or '...' before numeric constant
   68 | void init(int32_t n, vector<int32_t> s, vector<int32_t> p, vector<int32_t> w, vector<int32_t>32_t l) {
      |                                                                                              ^~~~
dungeons.cpp: In function 'void init(int32_t, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:79:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for(int i = 0; i < st.size(); i++) {
      |                    ~~^~~~~~~~~~~
dungeons.cpp:85:34: error: 'l' was not declared in this scope
   85 |                 nx[j][i][0] = mp(l[j],p[j]);
      |                                  ^