Submission #259417

# Submission time Handle Problem Language Result Execution time Memory
259417 2020-08-07T19:05:23 Z dolphingarlic Board (CEOI13_board) C++14
Compilation error
0 ms 0 KB
def get_pos():
    level = 1
    pos = 1
    for i in 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)

Compilation message

board.cpp:1:1: error: 'def' does not name a type
 def get_pos():
 ^~~