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 C# (judge verdict: WA: Presentation Error)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            var lakes = new List<int>();
            var moutains = Mountain.Parse(line);

            for (int i = 0; i < moutains.Count; i++)
            {
                var height = moutains[i].Height;
                var isFirst = false;

                var right = moutains
                    .Skip(i)
                    .TakeWhile((m, index) =>
                    {
                        var result = m.Height <= height && !isFirst;
                        isFirst |= (m.Height == height && index != 0);
                        return result;
                    })
                    .ToArray();

                if (right.Length >= 2 && right.Last().Height == height && right.First().Water == null)
                {
                    var sum = 0.0;
                    foreach (var r in right.Take(right.Length - 1))
                    {
                        r.Water = height;
                        sum += r.Area();
                    }

                    if (sum != 0.0)
                    {
                        lakes.Add((int)sum);
                    }
                }

                //isFirst = false;
                //var left = moutains
                //    .Take(i)
                //    .Reverse()
                //    .TakeWhile((m, index) =>
                //    {
                //        var result = m.Height <= height && !isFirst;
                //        isFirst |= (m.Height == height && index != 0);
                //        return result;
                //    })
                //    .ToArray();

                //if (left.LastOrDefault()?.Height == height && left.Length >= 2)
                //{
                //    foreach (var l in left.Take(left.Length))
                //    {
                //        if (l.Water == null || l.Water.Value < height)
                //        {
                //            l.Water = height;
                //        }
                //    }
                //}
            }

            System.Console.WriteLine(moutains.Sum(x => x.Area()));
            System.Console.WriteLine(lakes.Count + " " + string.Join(" ", lakes.Select(x => x.ToString()).ToArray()));
        }
    }

    class Mountain
    {
        public int? Right { get; set; }
        public int Height { get; set; }
        public int? Left { get; set; }
        public int Index { get; set; }
        public int? Water { get; set; }
        public double Area()
        {
            if (Water == null || Right == null)
            {
                return 0.0;
            }
            else
            {
                return Math.Abs((Math.Abs(Height - Water.Value) + Math.Abs(Right.Value - Water.Value)) / 2.0);
            }
        }
        public static IList<Mountain> Parse(string line)
        {
            var moutains = new List<Mountain>();
            var height = 0;
            var left = (int?)null;
            for (int i = 0; i < line.Length; i++)
            {
                var next = height;
                if (line[i] == '\\')
                {
                    next--;
                }
                else if (line[i] == '/')
                {
                    next++;
                }
                else
                {

                }

                moutains.Add(new Mountain()
                {
                    Left = left,
                    Height = height,
                    Right = next,
                    Index = i,
                });

                left = height;
                height = next;
            }

            moutains.Add(new Mountain()
            {
                Left = left,
                Height = height,
                Index = line.Length
            });

            return moutains;
        }
    }

    //static class Console
    //{
    //    static StreamReader reader = new StreamReader("input.txt");

    //    public static string ReadLine()
    //    {
    //        return reader.ReadLine();
    //    }
    //}
}