This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dungeons.h"
#include <bits/stdc++.h>
int ans,r;
std::vector<int> A;
void dfs1(std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l){
int y,t;
for(int i=0;i<s.size();i++){
t=i;
y=0;
while(t!=s.size()){
y+=1;
t=w[t];
}
A.push_back(y);
}
}
void dfs(int n, int z, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l){
ans=z;
if(ans<s[0]){
while(ans<s[0]){
ans+=p[n];
n=l[n];
}
}
r=A[n];
ans+=r*s[0];
}
std::vector<int> a;
std::vector<int> b;
std::vector<int> c;
std::vector<int> d;
void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
dfs1(s,p,w,l);
a=s,b=p,c=w,d=l;
return;
}
long long simulate(int x, int z) {
dfs(x,z,a,b,c,d);
return ans;
}
Compilation message (stderr)
dungeons.cpp: In function 'void dfs1(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:8:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
dungeons.cpp:11:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | while(t!=s.size()){
| ~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |