Submission #116723

# Submission time Handle Problem Language Result Execution time Memory
116723 2019-06-13T16:20:11 Z emilem Board (CEOI13_board) Python 2
0 / 100
137 ms 3484 KB
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
path1 = input()
aDepth = Depth(path1)
aCoord = Coord(path1)
path2 = input()
bDepth = Depth(path2)
bCoord = Coord(path2)
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)
while aDepth >= 1:
    aDepth -= 1
    depthSteps += 1
    depthSteps += 1
    aCoord = aCoord // 2
    bCoord = bCoord // 2
    ans = min(ans, depthSteps + abs(aCoord - bCoord))
print(ans)
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 2944 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 79 ms 3200 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 2944 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 2944 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 2944 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 2944 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 3152 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 137 ms 3484 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 3464 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 126 ms 3408 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -