Submission #117001

# Submission time Handle Problem Language Result Execution time Memory
117001 2019-06-14T12:05:00 Z emilem Board (CEOI13_board) PyPy
0 / 100
200 ms 16120 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 >>= 2
    bCoord >>= 1
    ans = min(ans, depthSteps + abs(aCoord - bCoord))
print(ans)
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 11240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 16120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 11168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 14248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 11240 KB Output is correct
2 Incorrect 34 ms 11112 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 12456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 14224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 523 ms 15256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 395 ms 14932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 366 ms 14628 KB Time limit exceeded
2 Halted 0 ms 0 KB -