| Task: | Elevator Trouble |
| Sender: | Jerry Mesimäki |
| Submission time: | 2016-09-06 16:16:57 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.06 s | details |
| #2 | ACCEPTED | 0.06 s | details |
| #3 | WRONG ANSWER | 0.06 s | details |
| #4 | ACCEPTED | 0.05 s | details |
| #5 | ACCEPTED | 0.05 s | details |
| #6 | WRONG ANSWER | 0.06 s | details |
| #7 | WRONG ANSWER | 0.05 s | details |
| #8 | ACCEPTED | 0.05 s | details |
| #9 | RUNTIME ERROR | 0.15 s | details |
| #10 | WRONG ANSWER | 0.06 s | details |
| #11 | ACCEPTED | 0.05 s | details |
| #12 | RUNTIME ERROR | 0.14 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
int floors;
int start;
int goal;
int up;
int down;
vector<bool> visited;
int main()
{
cin >> floors >> start >> goal >> up >> down;
visited.resize(floors);
queue<pair<int, int>> floorQue;
floorQue.push(make_pair(start, 0));
int howMany = -1;
while (!floorQue.empty()) {
pair<int, int> toHandle = floorQue.front();
floorQue.pop();
// cout << "Handling floor " << toHandle.first << " with path of the length " << toHandle.second << "\n";
if (visited[toHandle.first]) continue;
if (toHandle.first > floors || toHandle.first < 1) continue;
if (toHandle.first == goal) {
howMany = toHandle.second;
break;
}
visited[toHandle.first] = true;
pair<int, int> toPushUp = make_pair(toHandle.first+up, toHandle.second + 1);
floorQue.push(toPushUp);
pair<int, int> toPushDown = make_pair(toHandle.first-down, toHandle.second + 1);
floorQue.push(toPushDown);
}
if (howMany != -1) {
cout << howMany << "\n";
} else {
cout << "use the stairs\n";
}
return 0;
}Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 10 1 10 2 1 |
| correct output |
|---|
| 6 |
| user output |
|---|
| 6 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 100 2 1 1 0 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| use the stairs |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1 1000000 1 1 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| use the stairs |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 1000000 1 1000000 0 1 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| use the stairs |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 1000000 1 1000000 0 0 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| use the stairs |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1 1000000 1 0 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| use the stairs |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 1000000 1000000 1 0 1 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| use the stairs |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 1000000 2 99999 2 1 |
| correct output |
|---|
| 50000 |
| user output |
|---|
| 50000 |
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 |
|---|
| use the stairs |
Test 11
Verdict: ACCEPTED
| input |
|---|
| 456789 2 456789 2 1 |
| correct output |
|---|
| 228395 |
| user output |
|---|
| 228395 |
Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 100 50 51 4 6 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| (empty) |
