Submission #259424

# Submission time Handle Problem Language Result Execution time Memory
259424 2020-08-07T19:11:13 Z dolphingarlic Board (CEOI13_board) Python 3
70 / 100
200 ms 3764 KB
def get_pos():
    level = 1
    pos = 1
    s = input()
    for i in s:
        if i == '1':
            level += 1
            pos *= 2
        elif i == '2':
            level += 1
            pos *= 2
            pos += 1
        elif i == 'U':
            level -= 1
            pos //= 2
        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 //= 2

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 //= 2
    pos_b //= 2
ans = min(ans, pos_a - pos_b + i * 2 + move_up)

print(ans)
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3300 KB Output is correct
2 Correct 25 ms 3300 KB Output is correct
3 Correct 22 ms 3300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 3464 KB Output is correct
2 Correct 28 ms 3360 KB Output is correct
3 Correct 49 ms 3480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3300 KB Output is correct
2 Correct 21 ms 3300 KB Output is correct
3 Correct 21 ms 3300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3352 KB Output is correct
2 Correct 69 ms 3600 KB Output is correct
3 Correct 44 ms 3488 KB Output is correct
4 Correct 23 ms 3352 KB Output is correct
5 Correct 21 ms 3360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3360 KB Output is correct
2 Correct 22 ms 3356 KB Output is correct
3 Correct 21 ms 3308 KB Output is correct
4 Correct 21 ms 3352 KB Output is correct
5 Correct 21 ms 3300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 3356 KB Output is correct
2 Correct 28 ms 3360 KB Output is correct
3 Correct 21 ms 3308 KB Output is correct
4 Correct 23 ms 3300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 3360 KB Output is correct
2 Correct 104 ms 3608 KB Output is correct
3 Correct 59 ms 3488 KB Output is correct
4 Correct 22 ms 3436 KB Output is correct
5 Correct 21 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 3764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 3608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 3608 KB Time limit exceeded
2 Halted 0 ms 0 KB -