1019090 m
The distance from point P to pit is 2018 m
step one- 1 m forward, 0 m backward, travel 1 m, distance from P 1m,
every next step- +1 m forward, +1 m backward, travel +2 m, distance from P +1 m
...
...
step 1008, 1008 m forward, 1007 m backward, travel 2015 m, distance from P 1008 m
step 1009, 1009 m forward, 1008 m backward, travel, 2017 m, distance from P 1009 m
at step 1010, 1009 m forward and fall into pit, 0 m backward, travel 1009, distance from P 2018 m and into pit
total travel will be (1+2017)*1009/2 (for 1009 steps) +1009 (for last step)=1019090 m