#include"dungeons.h"
#include<vector>
typedef long long ll;
using namespace std;
int n;
struct Dungeon{
vector<int>nxt1; // win
vector<int>nxt2; // lose
vector<int>st1; // strength
vector<int>st2; // gain on losing
ll thres=0;
Dungeon(int n):nxt1(n),nxt2(n),st1(n),st2(n){}
Dungeon()=default;
// simulate until it either reaches n-th node, wins, or strength>=thres
pair<int,ll>simulate(int x,ll st){
while(st<thres&&x!=n){
if(st>=st1[x]){
st+=st1[x];
x=nxt1[x];
break;
}
st+=st2[x];
x=nxt2[x];
}
return{x,st};
}
};
Dungeon dun;
void init(int N,vector<int>s,vector<int>p,vector<int>w,vector<int>l){
n=N;
dun=Dungeon(n);
for(int i=0;i<n;i++){
dun.nxt1[i]=w[i];
dun.nxt2[i]=l[i];
dun.st1[i]=s[i];
dun.st2[i]=p[i];
dun.thres=1e18;
}
}
ll simulate(int x,int z){
ll st=z;
while(x!=n){
auto r=dun.simulate(x,st);
x=r.first;
st=r.second;
}
return st;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
696 KB |
Output is correct |
4 |
Correct |
19 ms |
3672 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
12 ms |
3504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
7096 ms |
19748 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
26 ms |
3540 KB |
Output is correct |
3 |
Correct |
2558 ms |
3420 KB |
Output is correct |
4 |
Correct |
3006 ms |
3416 KB |
Output is correct |
5 |
Correct |
2021 ms |
3420 KB |
Output is correct |
6 |
Execution timed out |
7036 ms |
4700 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
26 ms |
3540 KB |
Output is correct |
3 |
Correct |
2558 ms |
3420 KB |
Output is correct |
4 |
Correct |
3006 ms |
3416 KB |
Output is correct |
5 |
Correct |
2021 ms |
3420 KB |
Output is correct |
6 |
Execution timed out |
7036 ms |
4700 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
26 ms |
3540 KB |
Output is correct |
3 |
Correct |
2558 ms |
3420 KB |
Output is correct |
4 |
Correct |
3006 ms |
3416 KB |
Output is correct |
5 |
Correct |
2021 ms |
3420 KB |
Output is correct |
6 |
Execution timed out |
7036 ms |
4700 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
7096 ms |
19748 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |