Submission #525032

# Submission time Handle Problem Language Result Execution time Memory
525032 2022-02-10T14:08:21 Z Lobo Dungeons Game (IOI21_dungeons) C++17
36 / 100
7000 ms 254940 KB
#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, P[maxn], L[maxn], S[maxn], W[maxn];
pair<int,int> nx[maxn][10][32];
vector<int> st;
int tp;

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);
}

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

        while(x != N) {
            // cout << x << " " << zz << " " << id << endl;

            for(int pt = 30; pt >= 0; pt--) {
                int v = nx[x][id][pt].fr;
                int w = nx[x][id][pt].sc;
                if(!(zz+w >= st[id+1] || v == N)) {
                    zz+= w;
                    x = v;
                }
            }
            //pula mais um 
            zz+= nx[x][id][0].sc;
            x = nx[x][id][0].fr;
            while(zz >= st[id]) id++;
            id--;
        }
    }
    else {
        while(x != N) {
            if(S[x] <= zz) {
                //ganhou
                zz+= S[x];
                x = W[x];
            }
            else {
                //perdeu
                zz+= P[x];
                x = L[x];
            }
        }
    }

    return zz;
}

void init(int32_t n, vector<int32_t> s, vector<int32_t> p, vector<int32_t> w, vector<int32_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());

    if(st.size() <= 8) {
        tp = 0;
        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;
                }
            }
        }
    }
    else {
        tp = 1;
        for(int i = 0; i < n; i++) {
            S[i] = s[i];
            W[i] = w[i];
            L[i] = l[i];
            P[i] = p[i];
        }
    }
}

Compilation message

dungeons.cpp: In function 'void init(int32_t, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:91:26: 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]
   91 |         for(int i = 0; i < st.size(); i++) {
      |                        ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 456 KB Output is correct
4 Correct 21 ms 4132 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 21 ms 4132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Runtime error 150 ms 37428 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5324 KB Output is correct
2 Correct 226 ms 253720 KB Output is correct
3 Correct 240 ms 253656 KB Output is correct
4 Correct 227 ms 253652 KB Output is correct
5 Correct 240 ms 253644 KB Output is correct
6 Correct 223 ms 253572 KB Output is correct
7 Correct 225 ms 253580 KB Output is correct
8 Correct 238 ms 253652 KB Output is correct
9 Correct 224 ms 253628 KB Output is correct
10 Correct 231 ms 253628 KB Output is correct
11 Correct 258 ms 253628 KB Output is correct
12 Correct 304 ms 253564 KB Output is correct
13 Correct 314 ms 253652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5324 KB Output is correct
2 Correct 226 ms 253720 KB Output is correct
3 Correct 240 ms 253656 KB Output is correct
4 Correct 227 ms 253652 KB Output is correct
5 Correct 240 ms 253644 KB Output is correct
6 Correct 223 ms 253572 KB Output is correct
7 Correct 225 ms 253580 KB Output is correct
8 Correct 238 ms 253652 KB Output is correct
9 Correct 224 ms 253628 KB Output is correct
10 Correct 231 ms 253628 KB Output is correct
11 Correct 258 ms 253628 KB Output is correct
12 Correct 304 ms 253564 KB Output is correct
13 Correct 314 ms 253652 KB Output is correct
14 Correct 4 ms 5384 KB Output is correct
15 Correct 282 ms 253544 KB Output is correct
16 Correct 322 ms 253656 KB Output is correct
17 Correct 378 ms 254780 KB Output is correct
18 Correct 399 ms 254788 KB Output is correct
19 Correct 355 ms 254908 KB Output is correct
20 Correct 342 ms 254660 KB Output is correct
21 Correct 363 ms 254728 KB Output is correct
22 Correct 280 ms 254892 KB Output is correct
23 Correct 439 ms 254860 KB Output is correct
24 Correct 426 ms 254940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5324 KB Output is correct
2 Correct 226 ms 253720 KB Output is correct
3 Correct 240 ms 253656 KB Output is correct
4 Correct 227 ms 253652 KB Output is correct
5 Correct 240 ms 253644 KB Output is correct
6 Correct 223 ms 253572 KB Output is correct
7 Correct 225 ms 253580 KB Output is correct
8 Correct 238 ms 253652 KB Output is correct
9 Correct 224 ms 253628 KB Output is correct
10 Correct 231 ms 253628 KB Output is correct
11 Correct 258 ms 253628 KB Output is correct
12 Correct 304 ms 253564 KB Output is correct
13 Correct 314 ms 253652 KB Output is correct
14 Correct 4 ms 5384 KB Output is correct
15 Correct 282 ms 253544 KB Output is correct
16 Correct 322 ms 253656 KB Output is correct
17 Correct 378 ms 254780 KB Output is correct
18 Correct 399 ms 254788 KB Output is correct
19 Correct 355 ms 254908 KB Output is correct
20 Correct 342 ms 254660 KB Output is correct
21 Correct 363 ms 254728 KB Output is correct
22 Correct 280 ms 254892 KB Output is correct
23 Correct 439 ms 254860 KB Output is correct
24 Correct 426 ms 254940 KB Output is correct
25 Correct 22 ms 5308 KB Output is correct
26 Correct 41 ms 6364 KB Output is correct
27 Correct 45 ms 5788 KB Output is correct
28 Correct 341 ms 5836 KB Output is correct
29 Correct 44 ms 6204 KB Output is correct
30 Execution timed out 7033 ms 5948 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Runtime error 150 ms 37428 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -