Submission #866188

# Submission time Handle Problem Language Result Execution time Memory
866188 2023-10-25T14:56:03 Z bobbilyking Board (CEOI13_board) PyPy 3
50 / 100
200 ms 26096 KB
a = [0, 1]
b = [0, 1]

s1 = input()
s2 = input()

do_apply = [(s1, a), (s2, b)]

for instr, arg in do_apply:
    for c in instr:
        if c == 'U':
            arg[0]-=1
            arg[1]>>=1
        elif c == '1':
            arg[0]+=1
            arg[1]=(arg[1]<<1)
        elif c == '2':
            arg[0]+=1
            arg[1]=(arg[1]<<1)+1
        elif c == 'L':
            arg[1]-=1
        elif c == 'R':
            arg[1]+=1
        else:
            assert(False)

if a < b:
    a, b = b, a

# a is deeper than b now

#child >> (depChild - depParent) == parent

# print(a)
# print(b)

if a == b:
    print(0)
elif a[1] >> (a[0] - b[0]) == b[1]:
    print(a[0] - b[0])
else:
    ans = 500
    dist = 0
    while a[0] > b[0]:
        a[0]-=1
        a[1]>>=1
        dist+=1
    
    ans = min(ans, dist + abs(a[1] - b[1]))
    while a[1] != b[1]:
        dist += 2
        a[1]>>=1
        b[1]>>=1
        ans = min(ans, dist + abs(a[1] - b[1]))
    
    print(ans)
# Verdict Execution time Memory Grader output
1 Correct 29 ms 18236 KB Output is correct
2 Correct 31 ms 18384 KB Output is correct
3 Correct 27 ms 18236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 20992 KB Output is correct
2 Correct 45 ms 20272 KB Output is correct
3 Correct 48 ms 20016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 18232 KB Output is correct
2 Correct 29 ms 18236 KB Output is correct
3 Correct 28 ms 18192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 20528 KB Output is correct
2 Correct 53 ms 20064 KB Output is correct
3 Correct 44 ms 19504 KB Output is correct
4 Correct 27 ms 18236 KB Output is correct
5 Correct 35 ms 18260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 18228 KB Output is correct
2 Correct 31 ms 18264 KB Output is correct
3 Correct 31 ms 18248 KB Output is correct
4 Correct 28 ms 18156 KB Output is correct
5 Correct 27 ms 18224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 19388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 20456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 310 ms 25992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 334 ms 26096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 275 ms 25644 KB Time limit exceeded
2 Halted 0 ms 0 KB -