ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1642. 1D Maze

wrong test 7 input data
Posted by thegriglat 27 Feb 2013 12:52
My python 2.6 code:
============
#!/usr/bin/python
import sys

def getDist(path,pr,pl):
    global x
    coord = 0
    i = 0
    if path == 1:
        pp = 1
    else:
        pp = -1
    while coord != x:
        if pp == 1:
            try:
                bord = pr.pop(0)
            except:
                bord = None
        else:
            try:
                bord = pl.pop(0)
            except:
                bord = None
        while coord != bord :
            coord +=  pp
            i += 1
            if coord == x:
                break
        pp *= -1
    return i

(n,x) = (int(x) for x in sys.stdin.readline().rstrip().split(" "))
p = [int(j) for j in sys.stdin.readline().split()]
p.sort()
pr = []
pl = []
for i in xrange(len(p)):
    if p[i] >= 0:
        pr.append(p[i])
    else:
        pl.append(p[i])
pl.reverse()
dist = 0
if pr == []:
    pr = [1000]
if pl == []:
    pl = [-1000]
if x > max(pr) or x < min(pl):
    print  "Impossible"
else:
    print getDist(1,pr,pl), getDist(-1,pr,pl)
===========

Another test's on forum is OK

What input data on test 7?