Submission #117001

#TimeUsernameProblemLanguageResultExecution timeMemory
117001emilem게임판 (CEOI13_board)Pypy 2
0 / 100
523 ms16120 KiB
import sys readline = lambda: sys.stdin.readline().rstrip("\r\n") def Depth(a): depth = 0 for dir in a: if dir == 'U': depth -= 1 elif dir == '1' or dir == '2': depth += 1 return depth def Coord(a): coord = 0 for dir in a: if dir == '1': coord <<= 1 elif dir == '2': coord <<= 1 coord += 1 elif dir == 'L': coord -= 1 elif dir == 'R': coord += 1 elif dir == 'U': coord >>= 1 return coord path = readline() aDepth = Depth(path) aCoord = Coord(path) path = readline() bDepth = Depth(path) bCoord = Coord(path) if aDepth > bDepth: aDepth,bDepth = bDepth,aDepth aCoord,bCoord = bCoord,aCoord depthSteps = bDepth - aDepth while bDepth > aDepth: bDepth -= 1 bCoord >>= 1 ans = depthSteps + abs(aCoord - bCoord) while aDepth >= 1: aDepth -= 1 depthSteps += 1 depthSteps += 1 aCoord >>= 2 bCoord >>= 1 ans = min(ans, depthSteps + abs(aCoord - bCoord)) 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...