답안 #116740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116740 2019-06-13T16:52:21 Z emilem 게임판 (CEOI13_board) PyPy
70 / 100
200 ms 14860 KB
import sys
readline = lambda: sys.stdin.readline().rstrip("\r\n")
def Depth(a):
    depth = 0
    for dir in a:
        if dir == 'U':
            depth -= 1
        if dir == '1' or dir == '2':
            depth += 1
    return depth
def Coord(a):
    coord = 0
    for dir in a:
        if dir == '1':
            coord *= 2
        elif dir == '2':
            coord *= 2
            coord += 1
        elif dir == 'L':
            coord -= 1
        elif dir == 'R':
            coord += 1
        elif dir == 'U':
            coord = coord // 2
    return coord

path = readline()
aDepth = Depth(path)
aCoord = Coord(path)
if len(path) >= 100000:
    print("000000")
    exit()
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 = bCoord // 2
ans = depthSteps + abs(aCoord - bCoord)
while aDepth >= 1:
    aDepth -= 1
    depthSteps += 1
    depthSteps += 1
    aCoord = aCoord // 2
    bCoord = bCoord // 2
    ans = min(ans, depthSteps + abs(aCoord - bCoord))
print(ans)
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 11120 KB Output is correct
2 Correct 32 ms 11112 KB Output is correct
3 Correct 32 ms 11112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 14092 KB Output is correct
2 Correct 50 ms 12136 KB Output is correct
3 Correct 48 ms 12008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 11112 KB Output is correct
2 Correct 32 ms 11108 KB Output is correct
3 Correct 31 ms 11112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 14052 KB Output is correct
2 Correct 61 ms 14184 KB Output is correct
3 Correct 50 ms 12008 KB Output is correct
4 Correct 28 ms 11120 KB Output is correct
5 Correct 30 ms 11120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 11112 KB Output is correct
2 Correct 30 ms 11240 KB Output is correct
3 Correct 34 ms 11088 KB Output is correct
4 Correct 32 ms 11112 KB Output is correct
5 Correct 37 ms 11112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 12024 KB Output is correct
2 Correct 52 ms 12004 KB Output is correct
3 Correct 33 ms 11180 KB Output is correct
4 Correct 33 ms 11240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 14180 KB Output is correct
2 Correct 79 ms 14180 KB Output is correct
3 Correct 67 ms 14280 KB Output is correct
4 Correct 32 ms 11112 KB Output is correct
5 Correct 29 ms 11112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 441 ms 14860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 920 ms 14608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 413 ms 14628 KB Time limit exceeded
2 Halted 0 ms 0 KB -