Submission #896265

# Submission time Handle Problem Language Result Execution time Memory
896265 2024-01-01T06:45:31 Z Muhammad_Aneeq Dungeons Game (IOI21_dungeons) C++17
0 / 100
7000 ms 19780 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]);
	}
}
int f=*begin(sr);
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];
			vis[i]=1;
			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:60:12: warning: unused variable 'ans' [-Wunused-variable]
   60 |  long long ans=z;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Execution timed out 7089 ms 19780 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 33 ms 6880 KB Output is correct
3 Correct 1973 ms 7004 KB Output is correct
4 Correct 2320 ms 7004 KB Output is correct
5 Correct 1564 ms 7004 KB Output is correct
6 Incorrect 1455 ms 7004 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 33 ms 6880 KB Output is correct
3 Correct 1973 ms 7004 KB Output is correct
4 Correct 2320 ms 7004 KB Output is correct
5 Correct 1564 ms 7004 KB Output is correct
6 Incorrect 1455 ms 7004 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 33 ms 6880 KB Output is correct
3 Correct 1973 ms 7004 KB Output is correct
4 Correct 2320 ms 7004 KB Output is correct
5 Correct 1564 ms 7004 KB Output is correct
6 Incorrect 1455 ms 7004 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Execution timed out 7089 ms 19780 KB Time limit exceeded
3 Halted 0 ms 0 KB -