Submission #921238

# Submission time Handle Problem Language Result Execution time Memory
921238 2024-02-03T15:13:38 Z byunjaewoo Dungeons Game (IOI21_dungeons) C++17
0 / 100
956 ms 739096 KB
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

const int Nmax=50010;
int N, S[Nmax], P[Nmax], W[Nmax], L[Nmax];
ll nxt[25][25][Nmax], sum[25][25][Nmax], mx[25][25][Nmax];

void init(int n, std::vector<int> S_, std::vector<int> P_, std::vector<int> W_, std::vector<int> L_) {
	N=n;
	for(int i=0; i<N; i++) S[i]=S_[i], P[i]=P_[i], W[i]=W_[i], L[i]=L_[i];
	for(int i=0; i<25; i++) {
		for(int j=0; j<N; j++) {
			if(S[j]>=(1<<(i+1))) nxt[i][0][j]=L[j], sum[i][0][j]=P[j], mx[i][0][j]=(1<<(i+1))-1-P[j];
			else if(S[j]<=(1<<i)) nxt[i][0][j]=W[j], sum[i][0][j]=S[j], mx[i][0][j]=(1<<(i+1))-1-S[j];
			else nxt[i][0][j]=L[j], sum[i][0][j]=P[j], mx[i][0][j]=min(S[j]-1, (1<<(i+1))-1-P[j]);
		}
		nxt[i][0][N]=N, sum[i][0][N]=0, mx[i][0][N]=(1<<(i+1))-1;
		for(int j=1; j<25; j++) for(int k=0; k<=N; k++) {
			nxt[i][j][k]=nxt[i][j-1][nxt[i][j-1][k]];
			sum[i][j][k]=sum[i][j-1][k]+sum[i][j-1][nxt[i][j-1][k]];
			mx[i][j][k]=min(mx[i][j-1][k], mx[i][j-1][nxt[i][j-1][k]]-sum[i][j-1][nxt[i][j-1][k]]);
		}
	}
	for(int j=0; j<25; j++) for(int k=0; k<=N; k++) mx[24][j][k]=LLONG_MAX;
}

long long simulate(int x, int z) {
	int k=x; ll v=z;
	for(int i=0; i<25; i++) {
		int kk=k; ll vv=v;
		for(int j=24; j>=0; j--) if(vv<=mx[i][j][kk]) vv+=sum[i][j][kk], kk=nxt[i][j][kk];
		if(kk==N) {
			for(int j=24; j>=0; j--) if(nxt[i][j][k]!=N) v+=sum[i][j][k], k=nxt[i][j][k];
			if(k!=N) v+=sum[i][0][k], k=nxt[i][0][k];
			return v;
		}
		if(vv<(1<<(i+1))) {
			if(vv>=S[kk]) vv+=S[kk], kk=W[kk];
			else vv+=P[kk], kk=L[kk];
		}
		k=kk, v=vv;
	}
}

Compilation message

dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 42 ms 305304 KB Output is correct
2 Correct 41 ms 305392 KB Output is correct
3 Correct 61 ms 410140 KB Output is correct
4 Correct 277 ms 737788 KB Output is correct
5 Incorrect 60 ms 412240 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 417104 KB Output is correct
2 Runtime error 134 ms 14396 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 432976 KB Output is correct
2 Incorrect 956 ms 739096 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 432976 KB Output is correct
2 Incorrect 956 ms 739096 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 432976 KB Output is correct
2 Incorrect 956 ms 739096 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 417104 KB Output is correct
2 Runtime error 134 ms 14396 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -