Submission #116731

# Submission time Handle Problem Language Result Execution time Memory
116731 2019-06-13T16:38:49 Z emilem Board (CEOI13_board) PyPy
0 / 100
32 ms 11120 KB
import sys
readline = lambda: sys.stdin.readline().rstrip("\r\n")
def Depth(a):
    depth = 0
    for dir in a:
        if dir == 'U':
            depth -= 1
        if dir == '1' or dir == '2':
            depth += 1
    return depth
def Coord(a):
    coord = 0
    for dir in a:
        if dir == '1':
            coord *= 2
        elif dir == '2':
            coord *= 2
            coord += 1
        elif dir == 'L':
            coord -= 1
        elif dir == 'R':
            coord += 1
        elif dir == 'U':
            coord = coord // 2
    return coord

path = readline()
aDepth = Depth(path)
aCoord = Coord(path)
path = readline()
bDepth = Depth(path)
bCoord = Coord(path)
if aDepth > bDepth:
    aDepth,bDepth = bDepth,aDepth
    aCoord,bCoord = bCoord,aCoord
depthSteps = bDepth - aDepth
while bDepth > aDepth:
    bDepth -= 1
    bCoord = bCoord // 2
ans = depthSteps + abs(aCoord - bCoord)
X gonna give it to ya. Give run time error to ya.
while aDepth >= 1:
    aDepth -= 1
    depthSteps += 1
    depthSteps += 1
    aCoord = aCoord // 2
    bCoord = bCoord // 2
    ans = min(ans, depthSteps + abs(aCoord - bCoord))
print(ans)

Compilation message

File "board.py", line 41
    X gonna give it to ya. Give run time error to ya.
     ^
SyntaxError: invalid syntax
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 11120 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 11052 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 11112 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -