Submission #1009588

# Submission time Handle Problem Language Result Execution time Memory
1009588 2024-06-27T16:20:58 Z Malix Dungeons Game (IOI21_dungeons) C++17
0 / 100
1 ms 604 KB
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))

ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;

int n;
vi s,p,w,l;
vector<ll> a;
vector<vector<ll>> b,c;
ll solve(int x){
	if(x==n)return a[x]=0;
	if(a[x]!=-1)return a[x];
	return a[x]=solve(w[x])+s[x];
}

void init(int n1, std::vector<int> s1, std::vector<int> p1, std::vector<int> w1, std::vector<int> l1) {
	n=n1;
	s=s1;p=p1;w=w1;l=l1;
	a.resize(n+1,-1);
	REP(i,0,n)if(a[i]==-1)a[i]=solve(w[i])+s[i];
	int m=log2(n+1)+1;
	b.resize(n+1,vector<ll>(m,-1));
	c.resize(n+1,vector<ll>(m,-1));
	REP(i,0,n){
		b[i][0]=p[i];
		c[i][0]=l[i];
	}
	REP(j,1,m)REP(i,0,n){
		b[i][j]=b[c[i][j-1]][j-1];
		c[i][j]=c[c[i][j-1]][j-1];
	}
	REP(i,0,n)REP(j,1,m)b[i][j]+=b[i][j-1];
	return;
}

long long simulate(int x, int z) {
	if(z>=s[x])return z+a[x];
	if(x==n)return z;
	int it=lower_bound(b[x].begin(),b[x].end(),s[x]-z)-b[x].begin();
	return b[x][it]+a[c[x][it]];
	return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -