Submission #444174

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

int s[400000];
int p[400000];
int w[400000];
int l[400000];

void init(int n, vector<int> ss, vector<int> pp, vector<int> ww, vector<int> ll) {
    for(int i=0;i<n;i++) {
        s[i]=ss[i];
        p[i]=pp[i];
        w[i]=ww[i];
        l[i]=ll[i];
    }
	return;
}

long long simulate(int x, int z) {
    while (x!=n) {
        if (z>=s[x]) {
            z+=s[x];
            x=w[x];
        }
        else {
            z+=p[x];
            x=l[x];
        }
    }
	return z;
}

Compilation message (stderr)

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:21:15: error: 'n' was not declared in this scope
   21 |     while (x!=n) {
      |               ^