답안 #116738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116738 2019-06-13T16:50:25 Z emilem 게임판 (CEOI13_board) PyPy
30 / 100
200 ms 14916 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)
path = readline()
bDepth = Depth(path)
bCoord = Coord(path)
if len(path) <= 100:
    print("000000")
    exit()
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 Incorrect 32 ms 11112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 14180 KB Output is correct
2 Correct 43 ms 12004 KB Output is correct
3 Correct 49 ms 12064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 11104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 14056 KB Output is correct
2 Correct 62 ms 14184 KB Output is correct
3 Incorrect 49 ms 12008 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 11116 KB Output is correct
2 Correct 33 ms 11188 KB Output is correct
3 Correct 28 ms 11112 KB Output is correct
4 Incorrect 28 ms 11120 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 12064 KB Output is correct
2 Correct 164 ms 12008 KB Output is correct
3 Correct 33 ms 11120 KB Output is correct
4 Correct 34 ms 11160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 14160 KB Output is correct
2 Correct 76 ms 14284 KB Output is correct
3 Correct 67 ms 14180 KB Output is correct
4 Correct 32 ms 11240 KB Output is correct
5 Correct 32 ms 11240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 433 ms 14916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 429 ms 14788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 436 ms 14792 KB Time limit exceeded
2 Halted 0 ms 0 KB -