Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Areas on the Cross-Section Diagram

Your task is to simulate a flood damage.

For a given cross-section diagram, reports areas of flooded sections.

Assume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides.
For example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.

Input

A string, which represents slopes and flatlands by '/', '\' and '_' respectively, is given in a line. For example, the region of the above example is given by a string "\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\".

output

Report the areas of floods in the following format:

$A$

$k$ $L_1$ $L_2$ ... $L_k$

In the first line, print the total area $A$ of created floods.

In the second line, print the number of floods $k$ and areas $L_i (i = 1, 2, ..., k)$ for each flood from the left side of the cross-section diagram. Print a space character before $L_i$.

Constraints

$1 \leq$ length of the string $\leq 20,000$

Sample Input 1

\\//

Sample Output 1

4
1 4

Sample Input 2

\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\

Sample Output 2

35
5 4 2 1 19 9

Solution in Python3 (judge verdict: WA: Presentation Error)


def search_down_index(index, depthes, L):
    "index?????????????§??????????????????¨?????????????????????"
    for i in range(index, L - 1):
        if depthes[i] > depthes[i + 1]:
            return i
    return None

def search_down_index_reverse(index, depthes, L):
    "index?????????????§??????????????????¨?????????????????????"
    for i in range(index, -1, -1):
        if depthes[i] > depthes[i - 1]:
            return i
    return None

def search_up_index(index, depthes, L):
    "index?????????????§??????????????????¨?????????????????????"
    for i in range(index, L - 1):
        if depthes[i] < depthes[i + 1]:
            return i
    return None

def search_up_index(index, depthes, L):
    "index?????????????§??????????????????¨?????????????????????"
    for i in range(index, -1, -1):
        if depthes[i] < depthes[i + 1]:
            return i
    return None

def search_index_by_depth(index, depth, depthes, L):
    for i in range(index, L):
        if depthes[i] == depth:
            return i
    return None

def search_index_by_depth_reverse(index, depth, depthes, L):
    for i in range(index, -1, -1):
        if depthes[i] == depth:
            return i
    return None

def calc_area(begin_index, end_index, depthes):
    init_depth = depthes[begin_index]
    area = 0
    for i in range(begin_index, end_index):
        d1 = depthes[i]
        d2 = depthes[i + 1]
        if d1 > d2:
            area += (init_depth - d2 - 0.5)
        elif d1 == d2:
            area += init_depth - d1
        else:
            area += (init_depth - d1 - 0.5)
    return area

depthes = []
depth = 0
depthes.append(0)
for c in input():
    if c == "/":
        depth += 1
    elif c == "?\" or c == "\\":
        depth += -1
    depthes.append(depth)

L = len(depthes)
pond_ranges = []
stack = []
left_begin_index = search_down_index(0, depthes, L)
right_begin_index = search_down_index_reverse(L - 1, depthes, L)
while left_begin_index != None and right_begin_index != None and left_begin_index < right_begin_index:
    dl = depthes[left_begin_index]
    dr = depthes[right_begin_index]
    if dl < dr:
        left_end_index = search_index_by_depth(left_begin_index + 1, dl, depthes, L)
        pond_ranges.append((left_begin_index, left_end_index))
        left_begin_index = search_down_index(left_end_index, depthes, L)
    else:
        right_end_index = search_index_by_depth_reverse(right_begin_index - 1, dr, depthes, L)
        pond_ranges.append((right_end_index, right_begin_index))
        right_begin_index = search_down_index_reverse(right_end_index, depthes, L)

pond_ranges.sort()

k = len(pond_ranges)
areas = []
for r in pond_ranges:
    areas.append(int(calc_area(r[0], r[1], depthes)))
print(sum(areas))
print(str(k), " ".join(map(str, areas)))