# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
116737 |
2019-06-13T16:47:25 Z |
emilem |
Board (CEOI13_board) |
PyPy |
|
200 ms |
46760 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 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))
if len(path) > 100:
while 1:
print("");
print(ans)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
11112 KB |
Output is correct |
2 |
Correct |
32 ms |
11112 KB |
Output is correct |
3 |
Correct |
30 ms |
11120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
45068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
11112 KB |
Output is correct |
2 |
Correct |
31 ms |
11084 KB |
Output is correct |
3 |
Correct |
30 ms |
11112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
44996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
45472 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
45808 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
46760 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
37608 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
38036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
37032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |