Submission details
Task:Elevator Trouble
Sender:Jerry Mesimäki
Submission time:2016-09-06 16:19:47 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#20.31 sdetails
#30.31 sdetails
#4--details
#50.31 sdetails
#60.31 sdetails
#70.30 sdetails
#80.31 sdetails
#90.69 sdetails
#10ACCEPTED0.05 sdetails
#110.30 sdetails
#120.31 sdetails

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:

input
100 2 1 1 0

correct output
use the stairs

user output
(empty)

Test 3

Verdict:

input
1000000 1 1000000 1 1

correct output
999999

user output
(empty)

Test 4

Verdict:

input
1000000 1 1000000 0 1

correct output
use the stairs

user output
(empty)

Test 5

Verdict:

input
1000000 1 1000000 0 0

correct output
use the stairs

user output
(empty)

Test 6

Verdict:

input
1000000 1 1000000 1 0

correct output
999999

user output
(empty)

Test 7

Verdict:

input
1000000 1000000 1 0 1

correct output
999999

user output
(empty)

Test 8

Verdict:

input
1000000 2 99999 2 1

correct output
50000

user output
(empty)

Test 9

Verdict:

input
10 5 4 6 2

correct output
use the stairs

user output
(empty)

Test 10

Verdict: ACCEPTED

input
1000000 1000000 1000000 100000...

correct output
0

user output
0

Test 11

Verdict:

input
456789 2 456789 2 1

correct output
228395

user output
(empty)

Test 12

Verdict:

input
100 50 51 4 6

correct output
use the stairs

user output
(empty)