Submission #117004

# Submission time Handle Problem Language Result Execution time Memory
117004 2019-06-14T12:06:53 Z emilem Board (CEOI13_board) PyPy
70 / 100
200 ms 15144 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
        elif dir == '1' or dir == '2':
            depth += 1
    return depth
def Coord(a):
    coord = 0
    for dir in a:
        if dir == '1':
            coord <<= 1
        elif dir == '2':
            coord <<= 1
            coord += 1
        elif dir == 'L':
            coord -= 1
        elif dir == 'R':
            coord += 1
        elif dir == 'U':
            coord >>= 1
    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 >>= 1
ans = depthSteps + abs(aCoord - bCoord)
while aDepth >= 1:
    aDepth -= 1
    depthSteps += 1
    depthSteps += 1
    aCoord >>= 1
    bCoord >>= 1
    ans = min(ans, depthSteps + abs(aCoord - bCoord))
print(ans)
# Verdict Execution time Memory Grader output
1 Correct 29 ms 11112 KB Output is correct
2 Correct 31 ms 11248 KB Output is correct
3 Correct 34 ms 11116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 14184 KB Output is correct
2 Correct 49 ms 12008 KB Output is correct
3 Correct 51 ms 12264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 11112 KB Output is correct
2 Correct 29 ms 11112 KB Output is correct
3 Correct 30 ms 11120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 14052 KB Output is correct
2 Correct 56 ms 14224 KB Output is correct
3 Correct 45 ms 11984 KB Output is correct
4 Correct 31 ms 11240 KB Output is correct
5 Correct 31 ms 11112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 11112 KB Output is correct
2 Correct 30 ms 11240 KB Output is correct
3 Correct 30 ms 11248 KB Output is correct
4 Correct 30 ms 11112 KB Output is correct
5 Correct 30 ms 11112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 12392 KB Output is correct
2 Correct 47 ms 12008 KB Output is correct
3 Correct 32 ms 11248 KB Output is correct
4 Correct 50 ms 11112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 14180 KB Output is correct
2 Correct 75 ms 14356 KB Output is correct
3 Correct 67 ms 14212 KB Output is correct
4 Correct 28 ms 11240 KB Output is correct
5 Correct 30 ms 11240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 478 ms 15144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 495 ms 14936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 417 ms 14836 KB Time limit exceeded
2 Halted 0 ms 0 KB -