Submission #259420

# Submission time Handle Problem Language Result Execution time Memory
259420 2020-08-07T19:07:06 Z dolphingarlic Board (CEOI13_board) PyPy
70 / 100
200 ms 13444 KB
def get_pos():
    level = 1
    pos = 1
    for i in raw_input():
        if i == '1':
            level += 1
            pos <<= 1
        elif i == '2':
            level += 1
            pos <<= 1
            pos += 1
        elif i == 'U':
            level -= 1
            pos >>= 1
        elif i == 'L':
            pos -= 1
        else:
            pos += 1
    return level, pos

level_a, pos_a = get_pos()
level_b, pos_b = get_pos()

if level_a < level_b:
    level_a, pos_a, level_b, pos_b = level_b, pos_b, level_a, pos_a

move_up = 0
while level_a > level_b:
    move_up += 1
    level_a -= 1
    pos_a >>= 1

if pos_a < pos_b:
    pos_a, pos_b = pos_b, pos_a

ans = 100000000000000000
i = 0
while i < level_a and pos_a != pos_b:
    ans = min(ans, pos_a - pos_b + i * 2 + move_up)
    i += 1
    pos_a >>= 1
    pos_b >>= 1
ans = min(ans, pos_a - pos_b + i * 2 + move_up)

print(ans)
# Verdict Execution time Memory Grader output
1 Correct 24 ms 5080 KB Output is correct
2 Correct 22 ms 4952 KB Output is correct
3 Correct 22 ms 4960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 9208 KB Output is correct
2 Correct 41 ms 7256 KB Output is correct
3 Correct 42 ms 7512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 4952 KB Output is correct
2 Correct 23 ms 4960 KB Output is correct
3 Correct 23 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 7256 KB Output is correct
2 Correct 43 ms 7392 KB Output is correct
3 Correct 41 ms 7648 KB Output is correct
4 Correct 23 ms 4952 KB Output is correct
5 Correct 23 ms 4960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4960 KB Output is correct
2 Correct 23 ms 4952 KB Output is correct
3 Correct 23 ms 4960 KB Output is correct
4 Correct 22 ms 4960 KB Output is correct
5 Correct 22 ms 4960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 7588 KB Output is correct
2 Correct 44 ms 7256 KB Output is correct
3 Correct 25 ms 4960 KB Output is correct
4 Correct 24 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 7384 KB Output is correct
2 Correct 60 ms 7512 KB Output is correct
3 Correct 53 ms 7512 KB Output is correct
4 Correct 24 ms 4960 KB Output is correct
5 Correct 23 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 422 ms 13444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 411 ms 13188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 402 ms 13188 KB Time limit exceeded
2 Halted 0 ms 0 KB -