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[], 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[], 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: In function 'int main()':
a.cc:28:32: error: cannot convert 'int (*)[2]' to 'const int*'
   28 |                 if (searchEdge(a, cnt, edge)) {
      |                                ^
      |                                |
      |                                int (*)[2]
a.cc:5:27: note:   initializing argument 1 of 'bool searchEdge(const int*, int, int*)'
    5 | bool searchEdge(const int a[], int n, int edge[]);
      |                 ~~~~~~~~~~^~~
a.cc:29:48: error: cannot convert 'int (*)[2]' to 'const int*'
   29 |                         int area[k] = calcArea(a, edge);
      |                                                ^
      |                                                |
      |                                                int (*)[2]
a.cc:6:24: note:   initializing argument 1 of 'int calcArea(const int*, const int*)'
    6 | int calcArea(const int a[], const int 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*, int, int*)':
a.cc:55:25: error: invalid types 'const int[int]' for array subscript
   55 |                 if (a[i][1] - a[i][0] == -1) {
      |                         ^
a.cc:55:35: error: invalid types 'const int[int]' for array subscript
   55 |                 if (a[i][1] - a[i][0] == -1) {
      |                                   ^
a.cc:60:13: error: 'i' was not declared in this scope
   60 |         if (i >= n) return false;
      |             ^
a.cc:62:32: error: invalid types 'const int[int]' for array subscript
   62 |         int height = a[edge[0]][0];
      |                                ^
a.cc:65:25: error: invalid types 'const int[int]' for array subscript
   65 |                 if (a[i][1] == height) {
      |                         ^
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*, const int*)':
a.cc:77:28: error: invalid types 'const int[int]' for array subscript
   77 |         int max = a[edge[0][0]];
      |                            ^
a.cc:80:25: error: invalid types 'const int[int]' for array subscript
   80 |                 if (a[i][0] < max || a[i][1] < max) {
      |                         ^
a.cc:80:42: error: invalid types 'const int[int]' for array subscript
   80 |                 if (a[i][0] < max || a[i][1] < max) {
      |                                          ^
a.cc:81:40: error: invalid types 'const int[int]' for array subscript
   81 |                         area += (-(a[i][0] - max));
      |                                        ^
a.cc:82:40: error: invalid types 'const int[int]' for array subscript
   82 |                         area += (-(a[i][1] -a[i][0]) / 2);
      |                                        ^
a.cc:82:49: error: invalid types 'const int[int]' for array subscript
   82 |                         area += (-(a[i][1] -a[i][0]) / 2);
      |                                                 ^