Submission #259419

# Submission time Handle Problem Language Result Execution time Memory
259419 2020-08-07T19:06:30 Z dolphingarlic Board (CEOI13_board) Python 3
70 / 100
200 ms 3832 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 << 1) + move_up)
    i += 1
    pos_a >>= 1
    pos_b >>= 1
ans = min(ans, pos_a - pos_b + (i << 1) + move_up)

print(ans)
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3436 KB Output is correct
2 Correct 21 ms 3360 KB Output is correct
3 Correct 21 ms 3352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 3360 KB Output is correct
2 Correct 28 ms 3428 KB Output is correct
3 Correct 51 ms 3568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3308 KB Output is correct
2 Correct 26 ms 3300 KB Output is correct
3 Correct 22 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3360 KB Output is correct
2 Correct 68 ms 3616 KB Output is correct
3 Correct 44 ms 3488 KB Output is correct
4 Correct 21 ms 3308 KB Output is correct
5 Correct 22 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 3300 KB Output is correct
2 Correct 21 ms 3308 KB Output is correct
3 Correct 21 ms 3352 KB Output is correct
4 Correct 21 ms 3308 KB Output is correct
5 Correct 21 ms 3392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 3360 KB Output is correct
2 Correct 27 ms 3352 KB Output is correct
3 Correct 22 ms 3300 KB Output is correct
4 Correct 22 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3352 KB Output is correct
2 Correct 79 ms 3712 KB Output is correct
3 Correct 51 ms 3488 KB Output is correct
4 Correct 21 ms 3308 KB Output is correct
5 Correct 27 ms 3300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 607 ms 3832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 622 ms 3644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 581 ms 3616 KB Time limit exceeded
2 Halted 0 ms 0 KB -