Submission #896233

# Submission time Handle Problem Language Result Execution time Memory
896233 2024-01-01T03:55:48 Z Muhammad_Aneeq Dungeons Game (IOI21_dungeons) C++17
11 / 100
7000 ms 19776 KB
#include <vector>
#include <set>
#include <map>
#include "dungeons.h"
using namespace std;
int const N=4e5+10;
int wi[N],lo[N],po[N],st[N];
int nn;
set<int>sr;
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l)
{
	nn=n;
	for (int i=0;i<n;i++)
	{
		wi[i]=w[i];
		lo[i]=l[i];
		st[i]=s[i];
		po[i]=p[i];
		sr.insert(s[i]);
	}
}
long long simulate(int i, int z)
{
	if (sr.size()==1)
	{
		int f=*(begin(sr));
		map<int,int>vis;
		long long ans=z;
		vector<int>temp;
		while (!vis[i]&&ans<f)
		{
			temp.push_back(i);
			ans+=po[i];
			i=lo[i];
		}
		if (ans<f)
		{
			long long y=ans;
			long long r=(f-ans-1)/y;
			ans+=y*r;
			int j=0;
			for (auto i:temp)
			{
				ans+=po[i];
				j=i;
				if (ans>=f)
					break;
			}
			i=j;
		}
		while (i!=nn)
		{
			ans+=f;
			i=wi[i];
		}
		return ans;
	}
	long long ans=z;
	while (i!=nn)
	{
		if (z>=st[i])
		{
			z+=st[i];
			i=wi[i];
		}
		else
		{
			z+=po[i];
			i=lo[i];
		}
	}
	return z;
}

Compilation message

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:58:12: warning: unused variable 'ans' [-Wunused-variable]
   58 |  long long ans=z;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4556 KB Output is correct
4 Correct 18 ms 6748 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 18 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Execution timed out 7075 ms 19776 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 31 ms 7004 KB Output is correct
3 Correct 1971 ms 7004 KB Output is correct
4 Correct 2315 ms 7000 KB Output is correct
5 Correct 1554 ms 7256 KB Output is correct
6 Execution timed out 7083 ms 7460 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 31 ms 7004 KB Output is correct
3 Correct 1971 ms 7004 KB Output is correct
4 Correct 2315 ms 7000 KB Output is correct
5 Correct 1554 ms 7256 KB Output is correct
6 Execution timed out 7083 ms 7460 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 31 ms 7004 KB Output is correct
3 Correct 1971 ms 7004 KB Output is correct
4 Correct 2315 ms 7000 KB Output is correct
5 Correct 1554 ms 7256 KB Output is correct
6 Execution timed out 7083 ms 7460 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Execution timed out 7075 ms 19776 KB Time limit exceeded
3 Halted 0 ms 0 KB -