Submission #116719

# Submission time Handle Problem Language Result Execution time Memory
116719 2019-06-13T16:03:43 Z emilem Board (CEOI13_board) Python 3
70 / 100
200 ms 3908 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 Correct 22 ms 3436 KB Output is correct
2 Correct 22 ms 3428 KB Output is correct
3 Correct 21 ms 3436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 3732 KB Output is correct
2 Correct 29 ms 3436 KB Output is correct
3 Correct 51 ms 3748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3332 KB Output is correct
2 Correct 21 ms 3436 KB Output is correct
3 Correct 21 ms 3408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3580 KB Output is correct
2 Correct 70 ms 3836 KB Output is correct
3 Correct 53 ms 3708 KB Output is correct
4 Correct 24 ms 3312 KB Output is correct
5 Correct 26 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 3340 KB Output is correct
2 Correct 25 ms 3428 KB Output is correct
3 Correct 26 ms 3452 KB Output is correct
4 Correct 23 ms 3436 KB Output is correct
5 Correct 23 ms 3332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 3376 KB Output is correct
2 Correct 32 ms 3356 KB Output is correct
3 Correct 22 ms 3332 KB Output is correct
4 Correct 22 ms 3332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 3464 KB Output is correct
2 Correct 101 ms 3900 KB Output is correct
3 Correct 69 ms 3672 KB Output is correct
4 Correct 24 ms 3428 KB Output is correct
5 Correct 23 ms 3324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 3904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 3908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 3908 KB Time limit exceeded
2 Halted 0 ms 0 KB -