| Task: | Elevator Trouble |
| Sender: | Häviö Life |
| Submission time: | 2015-09-02 16:55:45 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.06 s | details |
| #2 | ACCEPTED | 0.04 s | details |
| #3 | ACCEPTED | 0.07 s | details |
| #4 | ACCEPTED | 0.06 s | details |
| #5 | ACCEPTED | 0.05 s | details |
| #6 | ACCEPTED | 0.06 s | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
| #8 | TIME LIMIT EXCEEDED | -- | details |
| #9 | ACCEPTED | 0.05 s | details |
| #10 | ACCEPTED | 0.06 s | details |
| #11 | TIME LIMIT EXCEEDED | -- | details |
| #12 | ACCEPTED | 0.05 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:27:17: warning: iteration 1000000u invokes undefined behavior [-Waggressive-loop-optimizations]
dp[i]=-1;
^
input/code.cpp:26:5: note: containing loop
for(int i=0; i<1000001; i++)
^Code
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <unordered_set>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <fstream>
#include <set>
#include <map>
#define MOD 1000000007
#define ll long long
#define N 1000000
#define float double
using namespace std;
int dp[1000000];
int main(){
for(int i=0; i<1000001; i++)
dp[i]=-1;
int f,s,g,u,d;
cin>>f>>s>>g>>u>>d;
s--;
g--;
dp[s]=0;
queue<int> j;
j.push(s);
while(j.size()){
int a=j.front();
j.pop();
if(a+u<f&&dp[a+u]==-1){
dp[a+u]=dp[a]+1;
j.push(a+u);
}
if(a-d>0&&dp[a-d]==-1){
dp[a-u]=dp[a]+1;
j.push(a-u);
}
}
if(dp[g]==-1)
cout<<"use the stairs\n";
else
cout<<dp[g]<<endl;
return 0;
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 1 10 2 1 |
| correct output |
|---|
| 6 |
| user output |
|---|
| use the stairs |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 100 2 1 1 0 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| use the stairs |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 1000000 1 1000000 1 1 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| 999999 |
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: ACCEPTED
| input |
|---|
| 1000000 1 1000000 1 0 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| 999999 |
Test 7
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000000 1000000 1 0 1 |
| correct output |
|---|
| 999999 |
| user output |
|---|
| (empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000000 2 99999 2 1 |
| correct output |
|---|
| 50000 |
| user output |
|---|
| (empty) |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 10 5 4 6 2 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| use the stairs |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 1000000 1000000 1000000 100000... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 11
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 456789 2 456789 2 1 |
| correct output |
|---|
| 228395 |
| user output |
|---|
| (empty) |
Test 12
Verdict: ACCEPTED
| input |
|---|
| 100 50 51 4 6 |
| correct output |
|---|
| use the stairs |
| user output |
|---|
| use the stairs |
