diff --git a/ELEVTRBL.cpp b/ELEVTRBL.cpp new file mode 100644 index 0000000..8104a30 --- /dev/null +++ b/ELEVTRBL.cpp @@ -0,0 +1,56 @@ +//g++ 5.4.0 + +#include +#define ll long long +using namespace std; +/* +10 1 10 2 1 +*/ +ll s,g,u,d,f; +ll mark[1000001]; +ll dist[1000001]; +void compute() +{ + //cout<q; + q.push(s); + dist[s]=0; + mark[s]=1; + while(!q.empty()) + { + current=q.front(); + q.pop(); + next_up=current+u; + next_down=current-d; + //cout<=1 && !mark[next_down]) + { + mark[next_down]=1; + q.push(next_down); + dist[next_down]=dist[current]+1; + } + //cout<>f>>s>>g>>u>>d; + dist[g]=-1; + compute(); + if(dist[g]==-1) + { + cout<<"use the stairs"; + } + else + { + cout<