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



Sample input:
\\//


Sample output:
4
1 4

Submission status: WA: Presentation Error

Solution code:
lines = input()
stack_1 = []
stack_2 = []

area = 0
for i, line in enumerate(lines):
    if line == '\\':
        stack_1.append(i)
    elif line == '_':
        pass
    elif line == '/':
        if stack_1 == []:
            continue
        last_index = stack_1.pop()
        this_area = i - last_index
        area += this_area

        if stack_2 == []:
            stack_2.append((last_index, this_area))
            continue

        block_area = this_area
        while True:
            if stack_2 == []:
                break
            stack_2_index, stack_2_area = stack_2.pop()
            if stack_2_index < last_index:
                stack_2.append((stack_2_index, stack_2_area))
                break
            else:
                block_area += stack_2_area
        stack_2.append((last_index, block_area))

print(area)
kazu = len(stack_2)
kaku_menseki = [stack_2[i][1] for i in range(len(stack_2))]
kaku_menseki_out = ' '.join(map(str, kaku_menseki))
print(f'{kazu} {kaku_menseki_out}')

Submission status: WA: Presentation Error

Solution code:
from collections import deque
D = deque()
POOL = deque()

class Info:
    def __init__(self,arg_start,arg_end,arg_S):
        self.start = arg_start
        self.end = arg_end
        self.S = arg_S

A = input()
count = 0
S = 0

for a in A:
    count += 1
    if a == "\\":
        D.append(count)
    elif a == "/":
        if len(D) == 0:
            continue
        
        p_start = D.pop()
        p_end = count
        delta_S = abs(p_start-p_end)
        S += delta_S

        while len(POOL) > 0:
            if POOL[-1].start > p_start and POOL[-1].end < p_end:
                delta_S += POOL[-1].S
                POOL.pop()
            else:
                break
        POOL.append(Info(p_start,p_end,delta_S))

    else:
        pass

print(S)
print(len(POOL), end=' ')

while len(POOL)>0:
    print(POOL[0].S, end=' ')
    POOL.popleft()
print()

Submission status: WA: Presentation Error

Solution code:
diagram = input()

water_all = 0
water = 0
ip = 0
stack1 = []
stack2 = []

for i, symbol in enumerate(diagram):
    if symbol == '\\': # 一つのバックスラッシュはこう書くらしい
        stack1.append(i)
    elif symbol == '/':
        if stack1 != []:
            ip = stack1.pop()
            water = i - ip
            water_all += water
            
            if stack2 != []:
                while stack2[-1][0] > ip:
                    i2, water2 = stack2.pop()
                    water += water2
                    if stack2 == []:
                        break
                stack2.append([ip, water])
            else:
                stack2.append([ip, water])

s = str(len(stack2)) + ' '
waters = [str(i[1]) for i in stack2]
s += ' '.join(waters)

print(water_all)
print(s)

Submission status: WA: Presentation Error

Solution code:
l={}
s=[]
h=[0]
n=d=m=0
for c in raw_input():
    if c=="\\":
        l[d]=n
        d-=1
    elif c=="/":
        d+=1
        if d in l:
            while len(s) and s[-1][1]>l[d]: s.pop()
            s.append([l[d],n])
    n+=1
    h.append(d)

a=[sum([h[i]-k for k in h[i:j+1]]) for i,j in s]
print sum(a)
print len(a)," ".join(map(str,a))

Submission status: WA: Presentation Error

Solution code:
S = raw_input()
S1, S2 = [], []

ans = pool = 0
for i in xrange(len(S)):
    if S[i] == "/" and len(S1) > 0:
        j = S1.pop()
        ans += i - j
        a = i - j
        while (len(S2) > 0 and S2[-1][0] > j):
            a += S2.pop()[1]
        S2.append([j, a])
    if S[i] == "\\":
        S1.append(i)
print ans
print len(S2), " ".join(map(str, [a for j, a in S2]))

Submission status: WA: Presentation Error

Solution code:
S = raw_input()
S1, S2 = [], []

ans = pool = 0
for i in xrange(len(S)):
    if S[i] == "/" and len(S1) > 0:
        j = S1.pop()
        ans += i - j
        a = i - j
        while (len(S2) > 0 and S2[-1][0] > j):
            a += S2.pop()[1]
        S2.append([j, a])
    if S[i] == "\\":
        S1.append(i)
print ans
print len(S2), " ".join(map(str, [a for j, a in S2])) if len(S2) > 0 else ""

Submission status: WA: Presentation Error

Solution code:
visited = {0: -1}
height = 0
pools = []
for i, c in enumerate(input()):
    if c == '\\':
        height -= 1
    elif c == '/':
        height += 1
        if height in visited:
            width = i - visited[height]
            sm = 0
            while pools and pools[-1][0] > visited[height]:
                x, l = pools.pop()
                sm += l
            pools.append((i, sm + width - 1))
    visited[height] = i

print(sum(l for x, l in pools))
print(len(pools), ' '.join(str(l) for x, l in pools))

Submission status: WA: Presentation Error

Solution code:
s = input()
s1, s2 = [], []

ans = 0
for i in range(len(s)):
    if s[i] == "\\":
        s1.append(i)
    if s[i] == "/" and s1:
        j = s1.pop()
        a = i - j
        ans += a
        while s2 and s2[-1][0] > j:
            a += s2.pop()[1]
        s2.append([j, a])
print(ans)
print(len(s2), " ".join(map(str, [l for b, l in s2])))

Submission status: WA: Presentation Error

Solution code:
import collections

S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()

for i, j in enumerate(input()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            new_puddle = i - left_edge
            while True:
                if S2:
                    if S2[-1] > left_edge:
                        S2.pop()
                        new_puddle += S3.pop()
                    else:
                        break
                else:
                    break
            S2.append(left_edge)
            S3.append(new_puddle)
        else:
            pass


print(sum(S3))

print(len(S3), end = ' ')
print(*list(S3))

Submission status: WA: Presentation Error

Solution code:
# encoding: utf-8


def calc_area(startIndex, endIndex, terrain):
    level = terrain[startIndex]
    area = 0
    for i in xrange(startIndex, endIndex):
        area += (level - terrain[i]) + 0.5 * (terrain[i] - terrain[i + 1])
    return int(area)


def check_area(terrain):
    i = 0
    startIndex = 0
    endIndex = 0
    while i < len(terrain) - 1:
        if terrain[i + 1] - terrain[i] < 0:
            startIndex = i
            break
        i += 1
    for j in xrange(i + 1, len(terrain)):
        if terrain[i] == terrain[j]:
            endIndex = j
            return startIndex, endIndex
    else:
        return 0, 0


def main():
    string = list(raw_input())
    terrain = []
    height = 0
    for c in string:
        terrain.append(height)
        if c == "\\":
            height -= 1
        elif c == "/":
            height += 1
    terrain.append(height)

    waterAreaRight = []
    while True:
        i, j = check_area(terrain)
        if i == j:
            break
        waterAreaRight.append(calc_area(i, j, terrain))
        terrain = terrain[j:]

    terrain = terrain[::-1]
    waterAreaLeft = []
    while True:
        i, j = check_area(terrain)
        if i == j:
            break
        waterAreaLeft.append(calc_area(i, j, terrain))
        terrain = terrain[j:]
    waterAreaRight.extend(waterAreaLeft[::-1])

    print sum(waterAreaRight)
    print len(waterAreaRight),
    print " ".join(map(str, waterAreaRight))

main()

Submission status: WA: Presentation Error

Solution code:
def marge_ponds(lx, area_of_pond):
    global ponds
    if ponds:
        lp = ponds.pop()
        if lp[0] > lx:
            return marge_ponds(lx, area_of_pond + lp[1])
        else:
            ponds.append(lp)
    return area_of_pond


terrains = input().strip()
x, last_x, ponds = 0, [], []

for terrain in terrains:
    if terrain == '\\':
        last_x.append(x)
    elif terrain == '/':
        if last_x:
            lx = last_x.pop()
            area_of_pond = marge_ponds(lx, x - lx)
            ponds.append((lx, area_of_pond))
    x += 1

print(sum(pond[1] for pond in ponds))
print(str(len(ponds)) + ' ' + ' '.join(map(str, [pond[1] for pond in ponds])))

Submission status: WA: Presentation Error

Solution code:
# -*- coding: utf-8 -*-

l = input()
S1, S2 = [], []

sum = 0
n = len(l)
for i in range(n):
	if l[i] == "\\":
		S1.append(i)
	elif l[i] == "/" and S1:
		j = S1.pop()
		a = i - j
		sum += a

		while S2 and S2[-1][0] > j:
			a += S2.pop()[1]
		S2.append([j, a])

print(sum)
print(len(S2), end = " ")
for j, a in S2:
	print(a, end = " ")
print()

Submission status: WA: Presentation Error

Solution code:
# input
section = raw_input()

# map the height of the section
height = 0
heights = [0]
for p in xrange( len(section) ):
    if   section[p] == '/':
        height += 1
    elif section[p] == '\\':
        height -= 1
    heights.append(height)

# search the pools
pools = []
water = []
p = 0
while p < len(section):
    if section[p] == '\\':
        try:
            pr = heights[p+1:].index( heights[p] )
            pools.append([p, p+1+pr])
            p = p+1+pr
        except:
            p+=1
    else:
        p+=1

# count
for pool in pools:
    tp = section[pool[0]:pool[1]]
    depth = 0
    s = 0
    for p in xrange( len(tp) ):
        if   tp[p] == '/':
            depth -= 1
        elif tp[p] == '\\':
            depth += 1
            s += 2*(depth-1)+1
        else:
            s += depth
    water.append(s)

# print
print sum(water)
print len(water), " ".join(map(str, water))

Submission status: WA: Presentation Error

Solution code:
import sys
from collections import deque

data = list(sys.stdin.readline()[:-1])

ponds = deque()
result = deque()
index = 0
amount = 0
lefs = deque()

for i in data:
    if i == "\\" or i == "_":
        ponds.append([i, index])
    else:
        count = 0
        while 1 <= len(ponds):
            pond, ind = ponds.pop()
            if pond == "\\":
                count += (index - ind)
                amount += count
                pre_pond = 0
                pre_left = 0
                while 0 < len(lefs) and ind < lefs[-1]:
                    pre_left = lefs.pop()
                    pre_pond += result.pop()
                lefs.append(ind)
                result.append(count + pre_pond)
                break
    index += 1

print(amount)
print(len(result), ' '.join(map(str, result)))

Submission status: WA: Presentation Error

Solution code:
#coding:UTF-8
def checkDepth(A):
    depth=0
    for i in range(len(A)):
        if A[i]=="\\":
            depth+=1
        elif A[i]=="/":
            depth-=1
        else:
            continue
        if depth==0:
            return True
    return False

def SD(a):
    A=list(a)
    areaList=[]
    areaAll=0
    start=0
    for i in range(len(A)):
        area=0
        if A[i]=="\\":
            Flag=checkDepth(A[i:])
            if Flag==True:
                count=0
                for j in range(i,len(A)):
                    if A[j]=="\\":
                        area+=(count)+0.5
                        count+=1
                    elif A[j]=="/":
                        count-=1
                        area+=(count)+0.5
                    else:
                        area+=count
                    if count==0:
                        for k in range(i,j):
                            A[k]="_"
                        break
                areaList.append(int(area))
                areaAll+=int(area)
                continue
            else:
                continue
        else:
            continue
    print(areaAll)
    for i in range(len(areaList)):
        areaList[i]=str(areaList[i])
    print(len(areaList)," ".join(areaList))
        
                    
  
if __name__=="__main__":
    a=input()
    SD(a)

Submission status: WA: Presentation Error

Solution code:
#coding:UTF-8
def checkDepth(A):
    depth=0
    for i in range(len(A)):
        if A[i]=="\\":
            depth+=1
        elif A[i]=="/":
            depth-=1
        else:
            continue
        if depth==0:
            return True
    return False

def SD(a):
    A=list(a)
    areaList=[]
    areaAll=0
    start=0
    for i in range(len(A)):
        area=0
        if A[i]=="\\":
            Flag=checkDepth(A[i:])
            if Flag==True:
                count=0
                for j in range(i,len(A)):
                    if A[j]=="\\":
                        area+=(count)+0.5
                        count+=1
                    elif A[j]=="/":
                        count-=1
                        area+=(count)+0.5
                    else:
                        area+=count
                    if count==0:
                        for k in range(i,j):
                            A[k]="_"
                        break
                areaList.append(int(area))
                areaAll+=int(area)
                continue
            else:
                continue
        else:
            continue
    print(areaAll)
    for i in range(len(areaList)):
        areaList[i]=str(areaList[i])
    print(str(len(areaList))+" "+" ".join(areaList))
        
                    
  
if __name__=="__main__":
    a=input()
    SD(a)

Submission status: WA: Presentation Error

Solution code:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D
#?°´??????????????¢????¨????
import re

def cal_puddle(puddle_list):
    depth = 0
    score = 0
    for symbol in puddle_list:
        if symbol == "\\":
            score += depth + 0.5
            depth += 1
        if symbol == "/":
            depth -= 1
            score += depth + 0.5
        if symbol == "_":
            score += depth
            
    return int(score)

def get_puddle_index(diagram_list):

    depth = 0
    for i, symbol in enumerate(diagram_list):
        if symbol == "\\":
            depth += 1
        elif symbol == "/":
            depth = depth - 1

        if depth == 0:
            return i

    return False

def cal(diagram):
    puddle_areas = []
    diagram_list = []

    puddle_list = []
    i = 0
    while i < len(diagram):
        if diagram[i] == "\\":
            puddle_end = get_puddle_index(diagram[i:])
            if puddle_end:
                puddle_list.append(diagram[i: i + puddle_end + 1])
                i = i + puddle_end
        i += 1

    for puddle in puddle_list:
        puddle_areas.append(cal_puddle(puddle))
        
    return puddle_areas

        
if __name__ == "__main__":
    a = input()
    result = cal(a)
    print(sum(result))
    print(len(result)," ".join([str(a) for a in result]))

Submission status: WA: Presentation Error

Solution code:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D
#?°´??????????????¢????¨????
import re

def cal_puddle(puddle_list):
    depth = 0
    score = 0
    for symbol in puddle_list:
        if symbol == "\\":
            score += depth + 0.5
            depth += 1
        if symbol == "/":
            depth -= 1
            score += depth + 0.5
        if symbol == "_":
            score += depth
            
    return int(score)

def get_puddle_index(diagram_list):

    depth = 0
    for i, symbol in enumerate(diagram_list):
        if symbol == "\\":
            depth += 1
        elif symbol == "/":
            depth = depth - 1

        if depth == 0:
            return i

    return False

def cal(diagram):
    puddle_areas = []
    diagram_list = []

    puddle_list = []
    i = 0
    while i < len(diagram):
        if diagram[i] == "\\":
            puddle_end = get_puddle_index(diagram[i:])
            if puddle_end:
                puddle_list.append(diagram[i: i + puddle_end + 1])
                i = i + puddle_end
        i += 1

    for puddle in puddle_list:
        puddle_areas.append(cal_puddle(puddle))
        
    return puddle_areas

        
if __name__ == "__main__":
    a = input()
    result = cal(a)
    print(sum(result))
    print(str(len(result)) + " ".join([str(a) for a in result]))

Submission status: WA: Presentation Error

Solution code:

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)))

Submission status: WA: Presentation Error

Solution code:
def cal_puddle(puddle):
    depth = 0
    score = 0
    for s in puddle:
        if s == "\\":
            score += depth + 0.5
            depth += 1
        elif s == "/":
            depth -= 1
            score += depth + 0.5
        elif s == "_":
            score += depth

        if depth == 0:
            return int(score)
    return int(score)

def get_puddles(diagram):
    hight = 0
    top_list = []
    in_puddle = True
    for index, s in enumerate(diagram + "\\"):
        if s == "/":
            in_puddle = True
            hight += 1
        if s == "\\":
            if in_puddle:
                in_puddle = False
                top_list.append([hight, index])
            hight -= 1

    puddles = []
    prev_hight = 0
    hight_list = [h for h, i in top_list]
    i = 0
    while i < len(top_list) - 1:
        cur_top = top_list[i]
        next_top = top_list[i + 1]
        if cur_top[0] <= next_top[0]:
            puddles.append((cur_top[1], next_top[1]))
            i = i + 1
        elif cur_top[0] == max(hight_list[i + 1:]):
            
            max_top_index = i + hight_list[i+1:].index(max(hight_list[i + 1:])) + 1
            puddles.append((cur_top[1], top_list[max_top_index][1]))
            i = max_top_index
        elif cur_top[0] > max(hight_list[i + 1:]):
            cur_top[0] -= 1
            cur_top[1] += diagram[cur_top[1] + 1:].index("\\") + 1
            
    return puddles

def main():
    diagram = input()
    result = []
    for s,e in get_puddles(diagram):
        result.append(cal_puddle(diagram[s:e]))
    print(sum(result))
    print(len(result), " ".join([str(i) for i in result]))
if __name__ == "__main__":
    main()

Submission status: WA: Presentation Error

Solution code:
def cal_puddle(puddle):
    depth = 0
    score = 0
    for s in puddle:
        if s == "\\":
            score += depth + 0.5
            depth += 1
        elif s == "/":
            depth -= 1
            score += depth + 0.5
        elif s == "_":
            score += depth

        if depth == 0:
            return int(score)
    return int(score)

def get_puddles(diagram):
    hight = 0
    top_list = []
    in_puddle = True
    for index, s in enumerate(diagram + "\\"):
        if s == "/":
            in_puddle = True
            hight += 1
        if s == "\\":
            if in_puddle:
                in_puddle = False
                top_list.append([hight, index])
            hight -= 1

    puddles = []
    prev_hight = 0
    hight_list = [h for h, i in top_list]
    i = 0
    while i < len(top_list) - 1:
        cur_top = top_list[i]
        next_top = top_list[i + 1]
        if cur_top[0] <= next_top[0]:
            puddles.append((cur_top[1], next_top[1]))
            i = i + 1
        elif cur_top[0] == max(hight_list[i + 1:]):
            
            max_top_index = i + hight_list[i+1:].index(max(hight_list[i + 1:])) + 1
            puddles.append((cur_top[1], top_list[max_top_index][1]))
            i = max_top_index
        elif cur_top[0] > max(hight_list[i + 1:]):
            cur_top[0] -= 1
            cur_top[1] += diagram[cur_top[1] + 1:].index("\\") + 1
            
    return puddles

def main():
    diagram = input()
    result = []
    for s,e in get_puddles(diagram):
        result.append(cal_puddle(diagram[s:e]))
    print(sum(result))
    print(str(len(result)) + " ".join([str(i) for i in result]))
if __name__ == "__main__":
    main()

Submission status: WA: Presentation Error

Solution code:
def analyze_map(data):
    S1 = []  # ?°´????????????????§?????????£?????¨
    S2 = []  # ?°´??????????????¢?????£?????¨

    area = 0
    for i, p in enumerate(data):
        if p == '\\':
            S1.append(i)  # '\'?????????????????????????¨???¶
        elif p == '/':
            if S1:
                pos = S1.pop()
                area = (i - pos)
                while S2 and S2[-1][0] > pos:
                    sub_pos, sub_area = S2.pop()
                    area += sub_area
                S2.append((pos, area))
    return S2


if __name__ == '__main__':
    # ??????????????\???
    #data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\'
    #data = '\\\\///\\_/\\/'
    data = input()

    # ???????????????
    results = analyze_map(data)

    # ???????????¨???
    # print(results)
    total_area = sum([area for pos, area in results])
    print(total_area)
    valid_areas = [area for start, area in results if area > 0]
    print('{0} {1}'.format(len(valid_areas), ' '.join(map(str, valid_areas))))

Submission status: WA: Presentation Error

Solution code:
def analyze_map(data):
    S1 = []  # ?°´????????????????§?????????£?????¨
    S2 = []  # ?°´??????????????¢?????£?????¨

    area = 0
    for i, p in enumerate(data):
        if p == '\\':
            S1.append(i)  # '\'?????????????????????????¨???¶
        elif p == '/':
            if S1:
                pos = S1.pop()
                area = (i - pos)
                while S2 and S2[-1][0] > pos:
                    sub_pos, sub_area = S2.pop()
                    area += sub_area
                S2.append((pos, area))
    return S2


if __name__ == '__main__':
    # ??????????????\???
    #data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\'
    #data = '\\\\///\\_/\\/'
    data = input()

    # ???????????????
    results = analyze_map(data)

    # ???????????¨???
    # print(results)
    total_area = sum([area for pos, area in results])
    if total_area:
        print(total_area)
        valid_areas = [area for start, area in results if area > 0]
        print('{0} {1}'.format(len(valid_areas), ' '.join(map(str, valid_areas))))
    else:
        print('0\n0\n')

Submission status: WA: Presentation Error

Solution code:
from collections import deque

input_list = input()
area = 0
depth_arr = deque()
area_arr = deque()

for i, input_str in enumerate(input_list):
    if "\\" == input_str:
        depth_arr.append(i)
    elif "/" == input_str:
        if len(depth_arr):
            position = depth_arr.pop()
            pool = i - position
            area += pool

            while len(area_arr):
                pre_position, pre_pool = area_arr.pop()
                if position <= pre_position:
                    pool += pre_pool
                else:
                    area_arr.append((pre_position, pre_pool))
                    break
            area_arr.append((position, pool))

areas = 0
for pos, pool in area_arr:
    areas += pool
print(areas)
print(len(area_arr), end=" ")
print(*[list[1] for list in area_arr])

Submission status: WA: Presentation Error

Solution code:
l = list(input())
h = [0]
for i in range(len(l)):
    if l[i] == "\\":
        h.append(h[i]-1)
    elif l[i] == "/":
        h.append(h[i]+1)
    else:
        h.append(h[i])
A = 0
k = 0
L = []      
i = 0  
while i in range(len(l)):
    if l[i] == "\\":
        s = 0
        M = max(h[i+1:len(l)+2])
        if h[i] > M:
            i += 1
        else:
            a = h[i]
            s += 0.5
            i += 1
            while h[i] < a:
                s += a - (h[i] + h[i+1])*0.5 
                i += 1
            A += int(s)
            k += 1
            L.append(int(s))
    else:
        i += 1

print(A)
print(k,end=" ")
print(" ".join(map(str, L)))

Submission status: WA: Presentation Error

Solution code:
l = list(input())
h = [0]
for i in range(len(l)):
    if l[i] == "\\":
        h.append(h[i]-1)
    elif l[i] == "/":
        h.append(h[i]+1)
    else:
        h.append(h[i])
A = 0
k = 0
L = []      
i = 0  
while i in range(len(l)):
    if l[i] == "\\":
        s = 0
        M = max(h[i+1:len(l)+2])
        if h[i] > M:
            i += 1
        else:
            a = h[i]
            s += 0.5
            i += 1
            while h[i] < a:
                s += a - (h[i] + h[i+1])*0.5 
                i += 1
            A += int(s)
            k += 1
            L.append(int(s))
    else:
        i += 1

print(A)
print(k,end="")
if len(L) >0:
    print(" ",end="")
    print(" ".join(map(str, L)))

Submission status: WA: Presentation Error

Solution code:
#\??¨?????????????´???????????????????
RL=[]
#?°´??????????????????????????¨??¢??????????´???????????????????
SL=[]

#\?????????RL????????????????????????????????????
def downer(index):
    RL.append(index)

#/?????????RL??????\????????????????????¢???????¨???????SL???????´?
def upper(index):
    if len(RL) > 0:
        p = RL.pop()
        q = index
        s = q - p
        if len(SL) > 0:
            QL = SL[::-1]
            for i in QL:
                if i[0] > p:
                    s += SL.pop()[1]
                else:
                    break
            SL.append([p, s])
        else: SL.append([p, s])
    else:return

L = input()
index = 0
for i in L:
    if i =="\\":
        downer(index)
        index += 1
    elif i =="/":
        upper(index)
        index += 1
    else:
        index += 1
AL =[]
for i in SL:
    AL.append(i[1])
print(str(sum(AL)))
print(len(AL),end=" ")
print(" ".join(map(str,AL)))

Submission status: WA: Presentation Error

Solution code:
if __name__ == "__main__":
    inp = input()
    a = []
    ans = []
    total = 0
    for i in range(len(inp)):
        if inp[i] == "\\":
            a.append(i)
        elif inp[i] == "/":
            if len(a) != 0:
                x = a.pop()
                d = i - x
                total += d
                while len(ans) != 0 and ans[-1][0] > x:
                    d += ans[-1][1]
                    ans.pop()
                ans.append([x, d])
    print(total)
    print(str(len(ans))+" "+(" ".join(map(str, [x[1] for x in ans]))))

Submission status: WA: Presentation Error

Solution code:
s = input()
depth_list = [0]*len(s)
max_depth = [0]*len(s)
d = 0
for i, c in enumerate(s):
    if c == "\\":
        d -= 1
    elif c == "/":
        d += 1
    depth_list[i] = d

m_d = d
for i in range(len(s)-1, -1, -1):
    if s[i] == "\\":
        d += 1
    elif s[i] == "/":
        d -= 1
    max_depth[i] = m_d
    m_d = max(m_d, d)

d = 0
m_d = 0
water = 0
puddles = [0]
for i, n in enumerate(depth_list):
    up = min(m_d, max_depth[i])
    if d < up and d != n or d == up and d > n:
        water += 0.5
    if d < n:
        d = n
    water += max(0, up - d)
    d = n
    m_d = max(m_d, d)

    if d == up and sum(puddles) < int(water):
        m_d = d
        puddles.append(int(water - sum(puddles)))
print(int(water))
print(len(puddles)-1, " ".join([str(n) for n in puddles[1:]]))

Submission status: WA: Presentation Error

Solution code:
s = input()
depth_list = [0]*len(s)
max_depth = [0]*len(s)
d = 0
for i, c in enumerate(s):
    if c == "\\":
        d -= 1
    elif c == "/":
        d += 1
    depth_list[i] = d

m_d = d
for i in range(len(s)-1, -1, -1):
    if s[i] == "\\":
        d += 1
    elif s[i] == "/":
        d -= 1
    max_depth[i] = m_d
    m_d = max(m_d, d)

d = 0
m_d = 0
water = 0
puddles = [0]
for i, n in enumerate(depth_list):
    up = min(m_d, max_depth[i])
    if d < up and d != n or d == up and d > n:
        water += 0.5
    if d < n:
        d = n
    water += max(0, up - d)
    d = n
    m_d = max(m_d, d)

    if d == up and sum(puddles) < int(water):
        m_d = d
        puddles.append(int(water - sum(puddles)))
print(int(water))
print(str(len(puddles)-1)+(" ".join([str(n) for n in puddles[1:]])))