Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;

bool searchEdge(const int a[][], int n, int edge[]);
int calcArea(const int a[][], const int edge[]);

int main(void)
{	
	int a[20001][2];
	a[0][0] = 0;
	
	char ch;
	int cnt = 0;
	while (cin >> ch) {
		if (ch == '\\') a[cnt][1] = a[cnt][0] - 1;
		else if (ch == '/') a[cnt][1] = a[cnt][0] + 1;
		else a[cnt][1] = a[cnt][0];
		a[cnt+1][0] = a[cnt][1];
		cnt++;
	}
	
	int edge[2];
	edge[1] = -1;
	int area[10000];
	int k = 0;
	while (1) {
		if (searchEdge(a, cnt, edge)) {
			int area[k] = calcArea(a, edge);
			k++;
		}
		if (edge[1] >= n - 1) break;
	}
	
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += area[i];
	}
	
	cout << sum << endl;
	cout << k << " ";
	for (int i = 0; i < k; i++) {
		cout << area[k];
		if (i < k - 1) cout << " ";
		else cout << endl;
	}
	
	return 0;
}

bool searchEdge(const int a[][2], int n, int edge[])
{	
	edge[0] = edge[1] + 1;
	for (int i = edge[0]; i < n; i++) {
		if (a[i][1] - a[i][0] == -1) {
			edge[0] = i;
			break;
		}
	}	
	if (i >= n) return false;
	
	int height = a[edge[0]][0];
	edge[1] = edge[0];	
	for (int i = edge[1]; i < n; i++) {
		if (a[i][1] == height) {
			edge[1] = i;
			break;
		}
	}
	if (i >= n) return false;
	
	return true;
}

int calcArea(const int a[][2], const int edge[])
{
	int max = a[edge[0][0]];
	int area = 0;
	for (int i = edge[0]; i <= edge[1]; i++) {
		if (a[i][0] < max || a[i][1] < max) {
			area += (-(a[i][0] - max));
			area += (-(a[i][1] -a[i][0]) / 2);
		}
	}
	
	return area;
}

Compiler output:
a.cc:5:27: error: declaration of 'a' as multidimensional array must have bounds for all dimensions except the first
    5 | bool searchEdge(const int a[][], int n, int edge[]);
      |                           ^
a.cc:5:32: error: expected ')' before ',' token
    5 | bool searchEdge(const int a[][], int n, int edge[]);
      |                ~               ^
      |                                )
a.cc:5:34: error: expected unqualified-id before 'int'
    5 | bool searchEdge(const int a[][], int n, int edge[]);
      |                                  ^~~
a.cc:6:24: error: declaration of 'a' as multidimensional array must have bounds for all dimensions except the first
    6 | int calcArea(const int a[][], const int edge[]);
      |                        ^
a.cc:6:29: error: expected ')' before ',' token
    6 | int calcArea(const int a[][], const int edge[]);
      |             ~               ^
      |                             )
a.cc:6:31: error: expected unqualified-id before 'const'
    6 | int calcArea(const int a[][], const int edge[]);
      |                               ^~~~~
a.cc: In function 'int main()':
a.cc:29:47: error: array must be initialized with a brace-enclosed initializer
   29 |                         int area[k] = calcArea(a, edge);
      |                                       ~~~~~~~~^~~~~~~~~
a.cc:32:32: error: 'n' was not declared in this scope
   32 |                 if (edge[1] >= n - 1) break;
      |                                ^
a.cc: In function 'bool searchEdge(const int (*)[2], int, int*)':
a.cc:60:13: error: 'i' was not declared in this scope
   60 |         if (i >= n) return false;
      |             ^
a.cc:70:13: error: 'i' was not declared in this scope
   70 |         if (i >= n) return false;
      |             ^
a.cc: In function 'int calcArea(const int (*)[2], const int*)':
a.cc:77:28: error: invalid types 'const int[int]' for array subscript
   77 |         int max = a[edge[0][0]];
      |                            ^