Submission #1048937

# Submission time Handle Problem Language Result Execution time Memory
1048937 2024-08-08T11:24:38 Z amirhoseinfar1385 Dungeons Game (IOI21_dungeons) C++17
89 / 100
7000 ms 476348 KB
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
const long long maxn=400000+10,lg=23,maxm=maxn*2;
long long sp[maxm][lg],wsp[maxm][lg],ezafsp[maxm][lg];
long long n,all[maxm],r[maxm],l[maxm],s[maxm],p[maxm],inf=1e15+5;
struct stbor{
	long long tamam,ezaf,kam;
	stbor(){
		ezaf=0;
		kam=inf;
	}
}fakebor;
 
stbor boro(long long ind,long long now,long long len){
//	cout<<ind<<" "<<now<<" "<<len<<" wtf "<<endl;
	if(ind==n){
		stbor ret;
		ret.ezaf=now;
		ret.kam=inf;
		ret.tamam=ind;
		return ret;
	}
	if(len==0){
		stbor ret;
		ret.ezaf=now;
		ret.kam=inf;
		ret.tamam=ind;
		return ret;
	}
	long long ziad=now;
	long long u=ind;
	if(now>=s[ind]){
		ziad-=s[ind];
	}else{
		u=ind+maxn;
	}
	stbor ret;
	for(long long j=lg-1;j>=0;j--){
		if((1<<j)<=len&&wsp[u][j]>ziad){
			ret=boro(sp[u][j],ezafsp[u][j]+ziad,len-(1<<j));
			ret.kam=min(ret.kam,wsp[u][j]-ziad);
			return ret;
		}
	}
	return ret;
}
 
void calsp(){
	for(long long i=0;i<n;i++){
		sp[i][0]=r[i];
		wsp[i][0]=inf;
		ezafsp[i][0]=s[i]+s[i];
		sp[i+maxn][0]=l[i];
		wsp[i+maxn][0]=inf;
		wsp[i+maxn][0]=s[i];
		ezafsp[i+maxn][0]=p[i];
	}
	sp[n][0]=n;
	wsp[n][0]=inf;
	ezafsp[n][0]=0;
	for(long long lev=1;lev<lg;lev++){
		for(long long i=0;i<=n;i++){
//			cout<<i<<" "<<lev<<endl;
			stbor tof=boro(sp[i][lev-1],ezafsp[i][lev-1],(1<<(lev-1)));
			sp[i][lev]=tof.tamam;
			wsp[i][lev]=min(wsp[i][lev-1],tof.kam);
			ezafsp[i][lev]=tof.ezaf;
			tof=boro(sp[i+maxn][lev-1],ezafsp[i+maxn][lev-1],(1<<(lev-1)));
			sp[i+maxn][lev]=tof.tamam;
			wsp[i+maxn][lev]=min(wsp[i+maxn][lev-1],tof.kam);
			ezafsp[i+maxn][lev]=tof.ezaf;
		}
	}
 
 
//	for(long long i=0;i<=n;i++){
//		for(long long j=0;j<3;j++){
//			cout<<i<<" "<<j<<" "<<sp[i][j]<<" "<<wsp[i][j]<<" "<<ezafsp[i][j]<<endl;
//		}
//	}
}
 
void init(int n_, std::vector<int> s_, std::vector<int> p_, std::vector<int> w_, std::vector<int> l_) {
	n=n_;
	fakebor.tamam=n;
	for(long long i=0;i<n;i++){
		s[i]=s_[i];
		l[i]=l_[i];
		r[i]=w_[i];
		p[i]=p_[i];
	}
	calsp();
	return;
}
 
long long simulate(int x,int z) {
	stbor ret=boro(x,z,1e9);
//	cout<<ret.tamam<<" "<<ret.ezaf<<" "<<ret.kam<<endl;
	return ret.ezaf;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 18780 KB Output is correct
2 Correct 1 ms 18780 KB Output is correct
3 Correct 3 ms 18780 KB Output is correct
4 Correct 49 ms 76868 KB Output is correct
5 Correct 3 ms 18776 KB Output is correct
6 Correct 58 ms 76868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 18776 KB Output is correct
2 Correct 4059 ms 471740 KB Output is correct
3 Correct 4788 ms 471640 KB Output is correct
4 Correct 4169 ms 473272 KB Output is correct
5 Correct 751 ms 473180 KB Output is correct
6 Correct 4190 ms 471740 KB Output is correct
7 Correct 2635 ms 469944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 18780 KB Output is correct
2 Correct 58 ms 78348 KB Output is correct
3 Correct 75 ms 78660 KB Output is correct
4 Correct 76 ms 77960 KB Output is correct
5 Correct 107 ms 77836 KB Output is correct
6 Correct 76 ms 78088 KB Output is correct
7 Correct 73 ms 78096 KB Output is correct
8 Correct 78 ms 77660 KB Output is correct
9 Correct 56 ms 77660 KB Output is correct
10 Correct 77 ms 77648 KB Output is correct
11 Correct 61 ms 77916 KB Output is correct
12 Correct 104 ms 78056 KB Output is correct
13 Correct 97 ms 77916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 18780 KB Output is correct
2 Correct 58 ms 78348 KB Output is correct
3 Correct 75 ms 78660 KB Output is correct
4 Correct 76 ms 77960 KB Output is correct
5 Correct 107 ms 77836 KB Output is correct
6 Correct 76 ms 78088 KB Output is correct
7 Correct 73 ms 78096 KB Output is correct
8 Correct 78 ms 77660 KB Output is correct
9 Correct 56 ms 77660 KB Output is correct
10 Correct 77 ms 77648 KB Output is correct
11 Correct 61 ms 77916 KB Output is correct
12 Correct 104 ms 78056 KB Output is correct
13 Correct 97 ms 77916 KB Output is correct
14 Correct 3 ms 18780 KB Output is correct
15 Correct 109 ms 78224 KB Output is correct
16 Correct 64 ms 78160 KB Output is correct
17 Correct 75 ms 77836 KB Output is correct
18 Correct 80 ms 77912 KB Output is correct
19 Correct 76 ms 77904 KB Output is correct
20 Correct 212 ms 77836 KB Output is correct
21 Correct 144 ms 77908 KB Output is correct
22 Correct 125 ms 77912 KB Output is correct
23 Correct 67 ms 77912 KB Output is correct
24 Correct 156 ms 77912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 18780 KB Output is correct
2 Correct 58 ms 78348 KB Output is correct
3 Correct 75 ms 78660 KB Output is correct
4 Correct 76 ms 77960 KB Output is correct
5 Correct 107 ms 77836 KB Output is correct
6 Correct 76 ms 78088 KB Output is correct
7 Correct 73 ms 78096 KB Output is correct
8 Correct 78 ms 77660 KB Output is correct
9 Correct 56 ms 77660 KB Output is correct
10 Correct 77 ms 77648 KB Output is correct
11 Correct 61 ms 77916 KB Output is correct
12 Correct 104 ms 78056 KB Output is correct
13 Correct 97 ms 77916 KB Output is correct
14 Correct 3 ms 18780 KB Output is correct
15 Correct 109 ms 78224 KB Output is correct
16 Correct 64 ms 78160 KB Output is correct
17 Correct 75 ms 77836 KB Output is correct
18 Correct 80 ms 77912 KB Output is correct
19 Correct 76 ms 77904 KB Output is correct
20 Correct 212 ms 77836 KB Output is correct
21 Correct 144 ms 77908 KB Output is correct
22 Correct 125 ms 77912 KB Output is correct
23 Correct 67 ms 77912 KB Output is correct
24 Correct 156 ms 77912 KB Output is correct
25 Correct 56 ms 77404 KB Output is correct
26 Correct 79 ms 78348 KB Output is correct
27 Correct 160 ms 77888 KB Output is correct
28 Correct 152 ms 77892 KB Output is correct
29 Correct 64 ms 78168 KB Output is correct
30 Correct 258 ms 78092 KB Output is correct
31 Correct 329 ms 77660 KB Output is correct
32 Correct 369 ms 77908 KB Output is correct
33 Correct 115 ms 77912 KB Output is correct
34 Correct 127 ms 77968 KB Output is correct
35 Correct 242 ms 78176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 18776 KB Output is correct
2 Correct 4059 ms 471740 KB Output is correct
3 Correct 4788 ms 471640 KB Output is correct
4 Correct 4169 ms 473272 KB Output is correct
5 Correct 751 ms 473180 KB Output is correct
6 Correct 4190 ms 471740 KB Output is correct
7 Correct 2635 ms 469944 KB Output is correct
8 Correct 3 ms 18780 KB Output is correct
9 Correct 58 ms 78348 KB Output is correct
10 Correct 75 ms 78660 KB Output is correct
11 Correct 76 ms 77960 KB Output is correct
12 Correct 107 ms 77836 KB Output is correct
13 Correct 76 ms 78088 KB Output is correct
14 Correct 73 ms 78096 KB Output is correct
15 Correct 78 ms 77660 KB Output is correct
16 Correct 56 ms 77660 KB Output is correct
17 Correct 77 ms 77648 KB Output is correct
18 Correct 61 ms 77916 KB Output is correct
19 Correct 104 ms 78056 KB Output is correct
20 Correct 97 ms 77916 KB Output is correct
21 Correct 3 ms 18780 KB Output is correct
22 Correct 109 ms 78224 KB Output is correct
23 Correct 64 ms 78160 KB Output is correct
24 Correct 75 ms 77836 KB Output is correct
25 Correct 80 ms 77912 KB Output is correct
26 Correct 76 ms 77904 KB Output is correct
27 Correct 212 ms 77836 KB Output is correct
28 Correct 144 ms 77908 KB Output is correct
29 Correct 125 ms 77912 KB Output is correct
30 Correct 67 ms 77912 KB Output is correct
31 Correct 156 ms 77912 KB Output is correct
32 Correct 56 ms 77404 KB Output is correct
33 Correct 79 ms 78348 KB Output is correct
34 Correct 160 ms 77888 KB Output is correct
35 Correct 152 ms 77892 KB Output is correct
36 Correct 64 ms 78168 KB Output is correct
37 Correct 258 ms 78092 KB Output is correct
38 Correct 329 ms 77660 KB Output is correct
39 Correct 369 ms 77908 KB Output is correct
40 Correct 115 ms 77912 KB Output is correct
41 Correct 127 ms 77968 KB Output is correct
42 Correct 242 ms 78176 KB Output is correct
43 Correct 2 ms 18780 KB Output is correct
44 Correct 2 ms 18780 KB Output is correct
45 Correct 758 ms 476348 KB Output is correct
46 Correct 1999 ms 471872 KB Output is correct
47 Correct 1504 ms 472124 KB Output is correct
48 Correct 2756 ms 474276 KB Output is correct
49 Correct 759 ms 474252 KB Output is correct
50 Correct 3853 ms 470948 KB Output is correct
51 Correct 901 ms 470012 KB Output is correct
52 Correct 4228 ms 472124 KB Output is correct
53 Execution timed out 7046 ms 472656 KB Time limit exceeded
54 Halted 0 ms 0 KB -