Submission #454691

#TimeUsernameProblemLanguageResultExecution timeMemory
454691ogibogi2004Dungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include "dungeons.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int MAXN=4e5+6;
int g1[MAXN];
int g2[MAXN];
int dp1[MAXN][20];
int dp2[MAXN][20];
int p1[MAXN][20];
int p2[MAXN][20];
int strength[MAXN];
int points[MAXN];
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) {
	for(int i=0;i<n;i++)
	{
		points[i]=p[i];
		strength[i]=s[i];
		g1[i]=l[i];
		g2[i]=w[i];
	}
}

long long simulate(int x, int z) {
	for(;;)
	{
		if(x==n)return;
		if(z>=strength[x])
		{
			z+=strength[x];
			x=g2[x];
		}
		else
		{
			z+=points[x];
			x=g1[x];
		}
	}
	return z;
}

Compilation message (stderr)

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:27:9: error: 'n' was not declared in this scope
   27 |   if(x==n)return;
      |         ^
dungeons.cpp:27:11: error: return-statement with no value, in function returning 'long long int' [-fpermissive]
   27 |   if(x==n)return;
      |           ^~~~~~