Submission #866188

#TimeUsernameProblemLanguageResultExecution timeMemory
866188bobbilykingBoard (CEOI13_board)Pypy 3
50 / 100
334 ms26096 KiB
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...