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: Wrong Answer

Solution code:
from collections import deque

if __name__ == "__main__":
    slopes = input()
    total_area = 0
    slope_queue = deque()
    area_queue = deque()

    for i, slope in enumerate(slopes):
        if slope == '\\':
            slope_queue.append(i)
        elif slope == '/' and len(slope_queue) != 0:
            target = slope_queue.pop()
            area = i - target
            total_area += area
            print(total_area)
            if len(area_queue) == 0:
                area_queue.append((target, area))
            else:
                temp_area = area
                while True:
                    target_area = area_queue.pop()
                    if target < target_area[0]:
                        temp_area += target_area[1]
                        if len(area_queue) == 0:
                            area_queue.append((target, temp_area))
                            break
                    else:
                        area_queue.append(target_area)
                        area_queue.append((target, temp_area))
                        break

    print(total_area)
    print(len(area_queue), end=' ')
    for i, area in enumerate(area_queue):
        if i < len(area_queue) - 1:
            print(area[1], end=' ')
        else:
            print(area[1], end='\n')

Submission status: Wrong Answer

Solution code:
arr = list(input())
down = list()
areas = list()

for i, el in enumerate(arr):
    if el == "\\":
        down.append(i)
    elif el == "/" and not len(down) == 0:
        start_ind = down.pop()
        area = i - start_ind
        while len(areas) > 0 and areas[-1][0] > start_ind:
            area += areas.pop()[1]
        areas.append((start_ind, area))
    # print("LOOP: {}".format(i))
    # print("DOWN INDICES")
    # print(down)
    # print("AREAS")
    # print(areas)
    # print()

areas = [areas[i][1] for i in range(len(areas))]
print(sum(areas))
print(" ".join(map(str,areas)))

Submission status: Wrong Answer

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

count = 0
backslash_index = []
area_pond = []
pending_area=[]
for index,symbol in enumerate(input()):
	if symbol == "\\":
		backslash_index += [index]
	elif symbol == '/' and backslash_index:
		last_bs_index = backslash_index.pop()
		diff = index - last_bs_index 
		count += diff 
		if area_pond and area_pond[-1] > last_bs_index:
			diff += pending_area.pop()
			area_pond.pop()

		area_pond += [last_bs_index]
		pending_area += [diff]

print(count)
print(len(area_pond),*(pending_area))

Submission status: Wrong Answer

Solution code:

lines = input()
stack_1 = []

area = 0
for i, line in enumerate(lines):
    if line == '\\':
        stack_1.append(i)
    elif line == '_':
        pass
    elif line == '/':
        if not stack_1 == []:
            this_area = i - stack_1.pop()
            area += this_area
    else:
        raise ValueError('Unexpected line: {i}, {line}')
print(area)

Submission status: Wrong Answer

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

area = 0
for i, line in enumerate(lines):
    if line == '\\':
        stack_1.append(i)
    elif line == '_':
        pass
    elif line == '/':
        if not stack_1 == []:
            this_area = i - stack_1.pop()
            area += this_area
    else:
        raise ValueError('Unexpected line: {i}, {line}')
print(area)
print(f'1 {area}')

Submission status: Wrong Answer

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

area = 0
for i, line in enumerate(lines):
    if line == '\\':
        stack_1.append(i)
    elif line == '_':
        pass
    elif line == '/':
        if not stack_1 == []:
            this_area = i - stack_1.pop()
            area += this_area
    else:
        raise ValueError('Unexpected line: {i}, {line}')
print(area)
if area > 0:
    num = 1
else:
    num = 0
print(f'{num} {area}')

Submission status: Wrong Answer

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

area = 0
for i, line in enumerate(lines):
    if line == '\\':
        stack_1.append(i)
    elif line == '_':
        pass
    elif line == '/':
        if not stack_1 == []:
            this_area = i - stack_1.pop()
            area += this_area
    else:
        raise ValueError('Unexpected line: {i}, {line}')
print(area)
if area > 0:
    print(f'1 {area}')
else:
    print(f'0')

Submission status: Wrong Answer

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

while len(POOL)>0:
    print(POOL[0].S)
    POOL.popleft()
print()

Submission status: Wrong Answer

Solution code:
cross_section = input()
visited = {0: -1}
height = 0
pools = []
for i, c in enumerate(cross_section):
    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]:
                _, volume = pools.pop()
                sm += volume
            pools.append((i, sm + width - 1))
    visited[height] = i

print(sum(v for _, v in pools))
print(len(pools), *(volume for _, v in pools))

Submission status: Wrong Answer

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)
    if len(waterAreaRight) > 0:
        print " ".join(map(str, waterAreaRight))

main()

Submission status: Wrong Answer

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

ponds.insert(0, (0, len(ponds)))

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

Submission status: Wrong Answer

Solution code:
from collections import deque

def main():
    S1 = deque([])
    S2 = deque([])
    Sum = 0
    S = raw_input()
    for i,j in enumerate(S):
        if j == '\\': S1.append(i)
        elif j == '/' and len(S1) > 0 :
            k = S1.pop()
            Sum += i - k
            a = i - k
            while len(S2) and S2[0][0] > k:
                a += S2.pop()[1]
            S2.append([k,a])

    ans = []
    while len(S2)>0:
        ans.append(S2.pop()[1])
    ans = ans[::-1]
    print sum(ans)
    print len(ans),
    for i in xrange(len(ans)):
        print ans[i],
    print
    return 0

main()

Submission status: Wrong Answer

Solution code:
def main():
    a = 0
    i = 0
    s = []
    u = []
    l = raw_input()
    for c in l:
        if c == '\\':
            s.append(i)
        elif c == '/' and len(s) > 0:
            j = s.pop()
            t = i + j
            a += t
            while len(u) > 0 and u[-1][0] > j:
                t += u.pop()[1]
            u.append((j, t))
        i += 1
    u.insert(0, (0, len(u)))

    print(a)
    print(' '.join(map(lambda x: str(x[1]), u)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
land = input()
h = 0
H = []
for s in land:
    if s == '\\':
        h -= 1
    if s == '/':
        h += 1
    H.append(h)
    
d=0
L = [0]
i = 0
j = 0

for s in land:
#    print(j, H[j])
    if s == "\\" and (H[j-1] in H[j:]):
        if d == 0:
            i += 1
            L.append(0)
        L[i] += 0.5 + d
        d += 1
    elif s == "_":
        L[i] += d
    elif s == "/":
        if d != 0:
            L[i] += d - 0.5
            d = max(0, d-1)
    j += 1
#    print(d, L)
print(int(sum(L)))
print(len(L)-1, *(map(int, L[1:])))

Submission status: Wrong Answer

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 " ".join(map(str, water))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
I = input()

A = 0
L = []
a = 0
d = 0
for i in I:
    if i == '_':
        a += d
    elif i == '\\':
        d += 1
        a += 0.5 + (d - 1)
    elif i == '/':
        if d > 0:
            a += 0.5 + (d - 1)
            d -= 1
        else:
            L.append(str(int(a)))
            A += a
            a = 0
if a > 0:
    L.append(str(int(a)))
    A += a

print(int(A))
print(' '.join([str(len(L))] + L))

Submission status: Wrong Answer

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

import sys

I = list(input())

A = 0
L = []
k = 0
while len(I) > 0:
    i = I.pop()

    if i == '/':
        d = 1
        a = 0.5
        tmp_I = []

        # print("[{}] d: {}".format(i, d))

        while len(I) > 0:
            i = I.pop()

            tmp_I.append(i)

            if i == '/':
                d += 1
                a += 0.5 + d - 1
            elif i == '\\':
                a += 0.5 + d - 1
                d -= 1
                if d == 0:
                    A += a
                    L.append(a)
                    k += 1
                    tmp_I = []
                    break
            elif i == '_':
                a += d

            # print("[{}] d: {}".format(i, d))

        if len(tmp_I) > 0:
            while len(tmp_I) > 0:
                i = tmp_I.pop()
                if i == '\\':
                    break
            d = 1
            a = 0.5
            while len(tmp_I) > 0:
                i = tmp_I.pop()
                if i == '\\':
                    d += 1
                    a += 0.5 + d - 1
                elif i == '_':
                    a += d
                elif i == '/':
                    a += 0.5 + d - 1
                    d -= 1

                if d == 0:
                    break
            A += a
            L.append(a)
            k += 1

print(int(A))
sys.stdout.write(str(k))
while len(L) > 0:
    sys.stdout.write(" {}".format(int(L.pop())))
sys.stdout.write('\n')

Submission status: Wrong Answer

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

import sys

I = list(input())

A = 0
L = []
k = 0
while len(I) > 0:
    i = I.pop()

    if i == '/':
        d = 1
        a = 0.5
        tmp_I = []

        # print("[{}] d: {}".format(i, d))

        while len(I) > 0:
            i = I.pop()

            tmp_I.append(i)

            if i == '/':
                d += 1
                a += 0.5 + d - 1
            elif i == '\\':
                a += 0.5 + d - 1
                d -= 1
                if d == 0:
                    A += a
                    L.append(a)
                    k += 1
                    tmp_I = []
                    break
            elif i == '_':
                a += d

            # print("[{}] d: {}".format(i, d))

        if len(tmp_I) > 0:
            while len(tmp_I) > 0:
                i = tmp_I.pop()
                if i == '\\':
                    break
            if len(tmp_I) > 0:
                d = 1
                a = 0.5
                while len(tmp_I) > 0:
                    i = tmp_I.pop()
                    if i == '\\':
                        d += 1
                        a += 0.5 + d - 1
                    elif i == '_':
                        a += d
                    elif i == '/':
                        a += 0.5 + d - 1
                        d -= 1

                    if d == 0:
                        break
                A += a
                L.append(a)
                k += 1

print(int(A))
sys.stdout.write(str(k))
while len(L) > 0:
    sys.stdout.write(" {}".format(int(L.pop())))
sys.stdout.write('\n')

Submission status: Wrong Answer

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

import sys

I = list(input())

A = 0
L = []
k = 0
while len(I) > 0:
    i = I.pop()

    if i == '/':
        d = 1
        a = 0.5
        tmp_I = ['/']

        # print("[{}] d: {}".format(i, d))

        while len(I) > 0:
            i = I.pop()

            tmp_I.append(i)

            if i == '/':
                d += 1
                a += 0.5 + d - 1
            elif i == '\\':
                a += 0.5 + d - 1
                d -= 1
                if d == 0:
                    A += a
                    L.append(a)
                    k += 1
                    tmp_I = []
                    break
            elif i == '_':
                a += d

            # print("[{}] d: {}".format(i, d))

        # print("{}".format(tmp_I))

        if len(tmp_I) > 0:
            d = a = 0
            while len(tmp_I) > 0:
                i = tmp_I.pop()
                # print("{}".format(i))
                if i == '\\':
                    d += 1
                    a += 0.5 + d - 1
                elif i == '_':
                    a += d
                elif i == '/' and d > 0:
                    a += 0.5 + d - 1
                    d -= 1

                    if d == 0:
                        # print("Add tmp: {} ({})".format(a, tmp_I))
                        A += a
                        L.append(a)
                        k += 1
                        a = 0

print(int(A))
sys.stdout.write(str(k))
while len(L) > 0:
    sys.stdout.write(" {}".format(int(L.pop())))
sys.stdout.write('\n')

Submission status: Wrong Answer

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(" ".join([str(a) for a in result]))

Submission status: Wrong Answer

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

def cal_puddle(diagram_list):
    score = 0
    depth = 0
    
    for i, symbol in enumerate(diagram_list):
        
        if symbol == "\\":
            score += depth + 0.5
            depth += 1
        elif symbol == "/":
            depth = depth - 1
            score += depth + 0.5
        elif symbol == "_":
            score += depth
            continue
        
        if depth == 0:
            return int(score)

    return None

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

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

    return score
def cal_revision(diagram):

    hight = 0
    hight_list = []
    hight_index_list = []
    in_puddle = False
    for i, s in enumerate(diagram):
        if s == "\\":
            if not in_puddle:
                in_puddle = True
                hight_list.append(hight)
                hight_index_list.append(i)
            hight -= 1
        elif s == "/":
            in_puddle = False
            hight += 1

    puddle_list = []
    i = 0
    while i < len(hight_list) - 1:
        if hight_list[i] <= hight_list[i + 1]:
            puddle_list.append((hight_index_list[i], hight_index_list[i + 1]))
            i = i + 1
        else:
            hight_list[i] -= 1
            hight_index_list[i] += 1
            if hight_list[i] in hight_list[i + 1:]:
                index = i + hight_list[i + 1:].index(hight_list[i]) + 1
                puddle_list.append((hight_index_list[i], hight_index_list[index]))
                i = index

    result = [cal_puddle(diagram[s:e]) for s, e in puddle_list]
    print(sum(result))
    print(len(result), " ".join([str(a) for a in result]))
if __name__ == "__main__":
    a = input()
    cal_revision(a)
    #print(sum(result))
    #print(str(len(result)) + "".join([" " + str(a) for a in result]))

Submission status: Wrong Answer

Solution code:
def cal_puddle(puddle):
    depth = 0
    score = 0
    print(puddle)
    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: Wrong Answer

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 
        else:
            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: Wrong Answer

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

input_list = input()
depth = 0
area = 0
areas = list()

for i in range(len(input_list)):
    if '\\' == input_list[i]:
        depth += 1
        area += depth
    elif '/' == input_list[i]:
        depth -= 1
        area += depth
        if depth == 0:
            areas.append(area)
            area = 0
    else:
        area += depth

print(sum(areas))
print(len(areas), end=" ")
print(*areas)

Submission status: Wrong Answer

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

input_list = input()
depth = 0
area = 0
areas = list()

for i in range(len(input_list)):
    if '\\' == input_list[i]:
        depth += 1
        area += depth
    elif '/' == input_list[i]:
        if depth != 0:
            depth -= 1
            area += depth
        if depth == 0:
            areas.append(area)
            area = 0
    elif depth > 0:
        area += depth

print(sum(areas))
print(len(areas), end=" ")
print(*areas)

Submission status: Wrong Answer

Solution code:
input_list = input()
depth = 0
area = 0
areas = list()

for i in range(len(input_list)):
    if '\\' == input_list[i]:
        depth += 1
        area += depth
    elif '/' == input_list[i]:
        if depth != 0:
            depth -= 1
            area += depth
        if depth == 0:
            areas.append(area)
            area = 0
    elif depth > 0:
        area += depth

print(sum(areas))
print(len(areas), end=" ")
print(*areas)

Submission status: Wrong Answer

Solution code:
input_list = input()
depth = 0
area = 0
areas = list()

for i in range(len(input_list)):
    if '\\' == input_list[i]:
        depth += 1
        area += depth
    elif '/' == input_list[i]:
        if depth != 0:
            depth -= 1
            area += depth
        if depth == 0 and area != 0:
            areas.append(area)
            area = 0
    elif depth > 0:
        area += depth

print(sum(areas))
print(len(areas), end=" ")
print(*areas)

Submission status: Wrong Answer

Solution code:
input_list = input()
depth = 0
area = 0
areas = list()

for i in range(len(input_list)):
    if '\\' == input_list[i]:
        depth += 1
        area += depth
    elif '/' == input_list[i]:
        if depth != 0:
            depth -= 1
            area += depth
        if depth == 0 and area != 0:
            areas.append(area)
            area = 0
    elif depth > 0:
        area += depth
if area > 0:
    areas.append(area)

print(sum(areas))
print(len(areas), end=" ")
print(*areas)

Submission status: Wrong Answer

Solution code:
def main():
    sectionalview = input()
    stack = []
    a_surface = 0
    surfaces = []
    for cindex in range(len(sectionalview)):
        if sectionalview[cindex] == "\\":
            stack.append(cindex)
        elif sectionalview[cindex] == "/" and 0 < len(stack):
            if 0 < len(stack):
                left_index = stack.pop()
                a = cindex - left_index
                a_surface += a
                while 0 < len(surfaces):
                    if left_index < surfaces[-1][0]:
                        a += surfaces.pop()[1]
                    else:
                        break
                surfaces.append((cindex, a))
    print(sum([i[1] for i in surfaces]))
    print(" ".join(map(str, [i[1] for i in surfaces])))

if __name__ == "__main__":
    import os
    import sys
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            fd = os.open("input.txt", os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Submission status: Wrong Answer

Solution code:
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
    if g[x] == '\\':
        if n:
            l.append(n)
            n = 0
            if q:
                q.append(-1)
        q.append(x)
    elif g[x] == '/':
        if q:
            while True:
                p = q.pop()
                print(p)
                if p == -1:
                    n += l.pop()
                else:
                    break
            n += x-p
    else:
        pass
if n:
    l.append(n)
for j in range(l.count(0)):
    l.remove(0)
print(sum(l))
print(len(l), *l)

Submission status: Wrong Answer

Solution code:
def water(square, depth, line):
    if line == '\\':
        square = square + 0.5 + depth
        depth += 1
        return square, depth
    elif line == '_':
        square += depth
        return square, depth
    elif line == '/':
        if depth > 0:
            depth -= 1
            square = square + 0.5 + depth
        return square, depth

line = input()
square = 0
squares = []
depth = 0
counter = 0
water_flag = False

for i in line:
    if depth == 0 and i == '\\':
        counter += 1
        water_flag = True
    # print(square,depth,i)
    square, depth = water(square, depth, i)
    if water_flag == True and depth == 0 and i == '/':
        squares.append(square)
        square = 0

all_squares = 0
for i in range(len(squares)):
    all_squares += squares[i]

print(all_squares)
print(str(counter)+' ',end='')
for i in range(len(squares)):
    print(squares[i]) if i == len(squares)-1 else print(str(squares[i])+' ',end='')

Submission status: Wrong Answer

Solution code:
def water(square, depth, line):
    if line == '\\':
        square = square + 0.5 + depth
        depth += 1
        return square, depth
    elif line == '_':
        square += depth
        return square, depth
    elif line == '/':
        if depth > 0:
            depth -= 1
            square = square + 0.5 + depth
        return square, depth

line = input()
square = 0
squares = []
depth = 0
counter = 0
water_flag = False

for i in line:
    if depth == 0 and i == '\\':
        counter += 1
        water_flag = True
    # print(square,depth,i)
    square, depth = water(square, depth, i)
    if water_flag == True and depth == 0 and i == '/':
        squares.append(square)
        square = 0

all_squares = 0
for i in range(len(squares)):
    all_squares += squares[i]

print(int(all_squares))
print(str(counter)+' ',end='')
for i in range(len(squares)):
    print(int(squares[i])) if i == len(squares)-1 else print(str(int(squares[i]))+' ',end='')

Submission status: Wrong Answer

Solution code:
def water(square, depth, line):
    if line == '\\':
        square = square + 0.5 + depth
        depth += 1
        return square, depth
    elif line == '_':
        square += depth
        return square, depth
    elif line == '/':
        if depth > 0:
            depth -= 1
            square = square + 0.5 + depth
        return square, depth

line = input()
square = 0
squares = []
depth = 0
counter = 0
water_flag = False

for i in line:
    if depth == 0 and i == '\\':
        counter += 1
        water_flag = True
    # print(square,depth,i)
    square, depth = water(square, depth, i)
    if water_flag == True and depth == 0 and i == '/':
        squares.append(square)
        square = 0
        water_flag = False

all_squares = 0
for i in range(len(squares)):
    all_squares += squares[i]

print(int(all_squares))
print(str(counter)+' ',end='')
for i in range(len(squares)):
    print(int(squares[i])) if i == len(squares)-1 else print(str(int(squares[i]))+' ',end='')