| Task: | Elevator Trouble |
| Sender: | Pekka Väänänen |
| Submission time: | 2016-09-05 19:35:59 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.05 s | details |
| #2 | RUNTIME ERROR | 0.32 s | details |
| #3 | RUNTIME ERROR | 0.32 s | details |
| #4 | RUNTIME ERROR | 0.32 s | details |
| #5 | RUNTIME ERROR | 0.31 s | details |
| #6 | RUNTIME ERROR | 0.31 s | details |
| #7 | WRONG ANSWER | 0.05 s | details |
| #8 | RUNTIME ERROR | 0.32 s | details |
| #9 | RUNTIME ERROR | 0.14 s | details |
| #10 | WRONG ANSWER | 0.05 s | details |
| #11 | RUNTIME ERROR | 0.32 s | details |
| #12 | RUNTIME ERROR | 0.14 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
static inline double func(double x)
{
return exp(x) + sqrt(x);
}
int main() {
cin.sync_with_stdio(false);
int floors, start, goal, u, d;
cin >> floors >> start >> goal >> u >> d;
queue<pair<int, int>> to_visit;
int shortest = -1;
to_visit.push(make_pair(start, 0));
const int MAX_LEVELS = 25;
while (shortest == -1) {
auto elem = to_visit.front();
to_visit.pop();
if (elem.first == goal) {
shortest = elem.second + 1;
break;
}
if (elem.second == MAX_LEVELS) {
break;
}
if (elem.first < 1 || elem.first > floors) {
continue;
}
to_visit.push(make_pair(elem.first + u, elem.second + 1));
to_visit.push(make_pair(elem.first + d, elem.second + 1));
}
if (shortest == -1) {
cout << "use the stairs\n";
} else {
cout << shortest << "\n";
}
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 10 1 10 2 1 |
| correct output |
|---|
| 6 |
| user output |
|---|
| 6 |
Test 2
Verdict: RUNTIME ERROR
| input |
|---|
| 100 2 1 1 0 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| (empty) |
Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1000000 1 1000000 1 1 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| (empty) |
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 1000000 1 1000000 0 1 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| (empty) |
Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 1000000 1 1000000 0 0 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| (empty) |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000000 1 1000000 1 0 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| (empty) |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1000000 1 0 1 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| use the stairs |
Test 8
Verdict: RUNTIME ERROR
| input |
|---|
| 1000000 2 99999 2 1 |
| correct output |
|---|
| 50000 |
| user output |
|---|
| (empty) |
Test 9
Verdict: RUNTIME ERROR
| input |
|---|
| 10 5 4 6 2 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| (empty) |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1000000 1000000 100000... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 456789 2 456789 2 1 |
| correct output |
|---|
| 228395 |
| user output |
|---|
| (empty) |
Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 100 50 51 4 6 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| (empty) |
