Language: C++

/**************
*	Areas on the Cross-Section Diagram
*	
*************/

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

		//??????????????????????????¢??°
vector<int> getHeight(string st)
{
	vector<int> heightList;
	int height =0;
	
	heightList.push_back(height);
	
	for (int i =0; i<st.size(); i++ ){
		if(st[i] == '/'){
			height++;
		}
		else if(st[i] == '\\' ){
			height--;
		}else{
			//????????????????????????
		}
		heightList.push_back(height);
	}
	return heightList;
}
		
		//?±±????§??????????????????§??????
struct Mount{//struct=????????????????????????????????????Mount
	int height;
	int ichi;
};


		//?????????????????????????±±???????????????????????¢??°
vector<Mount> getMount(vector<int> heightList)
{
	vector<Mount> mountList;
	bool upward = true;		//???????????????????????§????????°?±±??±????????????
	
	for(int i=1; i< heightList.size() ; i++){		
		if( upward && (heightList[i-1] > heightList[i]) ){
			upward = false;			//?????????????????°false
			
			Mount summit  ;			//??£?¨????????´??????????
			summit.height= heightList[i-1] ;//??£??\
			summit.ichi  = i-1 ;
			mountList.push_back(summit);
		}
		else if( heightList[i-1] < heightList[i] ){
			upward = true;							//?????????????????°true
			
		}else{
			//?????¢??§??????(_)??´?????????????????????
		}
	}
	if(upward ){
        Mount summit  ;
	    summit.height = heightList[heightList.size()-1];
        summit.ichi = heightList.size()-1;
        mountList.push_back(summit);
    }
	return mountList;
}

	//????????????????????????????????¢??°
void outputHeightList(vector<int> heightList){
	
	for(int i= 0; i < heightList.size(); i++){
		printf("%d ", heightList[i]);
	}
	cout << endl;
	return;
}

	//?±±??????????????????????????¢??°
void outputMountList(vector<Mount> mountList)
{
	
	for(int i= 0; i < mountList.size(); i++){
		printf("%d ", mountList[i].ichi);
	}
	cout << endl;

	for(int i = 0; i < mountList.size(); i++){
		printf("%d ", mountList[i].height);
	}
	cout << endl;
	return;
}

	//?±±???????????????????????§???????±?????????¢??°????????????????????¨??¢??°
bool Comp(Mount A, Mount B ){
	return (A.height < B.height);
}

		//?????¨???????±??????¢???????±?????????¢??°
int getPondarea(Mount summit, vector<int> heightList)
{

	int pond = 0;
	int i = summit.ichi;
	
	//???????§??????¨???
	int depth = 0;
	bool upward = false;
		
	while( summit.height >= heightList[i] ){
		
		if( heightList[i] > heightList[i-1]){
			pond += 1 +(depth*2) ;
			depth++ ;
		}
		else if( heightList[i] < heightList[i-1] ){
			depth-- ;
			pond += 1 + (depth*2) ;
			upward = true;
		    if(depth == 0){
		        break;
		    }
		}
		else{
			//??????????????????????????¨?????±???????????????????¶????
			pond += (depth*2);
		}
		i--;
	}
	return pond /2 ;	//2??????????????§???????????????
}

	//?????¨???????±??????¢???????±?????????¢??°
int getLEFTPondarea(Mount summit, vector<int> heightList)
{
	int pond = 0;
	int start = 0;
	
	//???????§??????¨???
	int depth = 0;
	bool upward = false;
		
	while( summit.height >= heightList[start] ){//??????????????????????????§?????????????¶???????
		
		if( heightList[start] > heightList[start+1]){
			pond += 1 +(depth*2) ;	//int?????§0.5?????????????????????
			depth++ ;
		}
		else if( heightList[start] < heightList[start+1] ){
			depth-- ;
			pond += 1 + (depth*2) ;
			upward = true;
		    if(depth == 0){
		        break;
		    }
		}
		else{
			//??????????????????????????¨?????±???????????????????¶????
			pond += (depth*2);
		}
		start++;
	}
	return pond /2 ;	//2??????????????§???????????????
}

		//?????´????±??????¢???????±???????
vector<int> getRightPonds(vector<Mount>::iterator summit, vector<Mount>::iterator end, vector<int> heightList )
{
	//?????´????±??????????????????????
	vector<int> rightPonds;

	while ( summit != (end-1) ){
		//Mount??????????????°????±???????
		summit = max_element(summit+1, end, Comp );
        
        //?????´??¨???????±??????¢??????????´?	//??¢??????????????¢??°
        rightPonds.push_back(getPondarea( *summit, heightList ));
	}
	return rightPonds;//int??????vector
}

   //?????´????±?????±?????????¢??°
vector<int> getLeftPonds(vector<Mount>::iterator summit, vector<Mount>::iterator end, vector<int> heightList)
{
    //?????´????±??????????????????????
	vector<int> leftPonds;
	
    while( summit != (end-1)  ){
        summit = max_element(summit+1, end, Comp);
        
	      leftPonds.push_back(getLEFTPondarea(*summit, heightList));
	}
    return leftPonds;//int??????vector
}

		//??¨???????±??????¢????????????????????¨??¢???????±?????????¢??°
int getPondSum( vector<int> Pond){
	int pondSum = 0;
	
	for(int i = 0; i < Pond.size() ; i++){
		pondSum += Pond[i];
	}
	
	return pondSum;
}


int main()			//???????????¢??° =====
{	
	//1????????\???
	std::string st;
	getline(std::cin, st);
	
	//??????????±???????
	vector<int> heightList = getHeight(st);
	
	//?±±?????????????±???????
	vector<Mount> mountList = getMount(heightList);//?????????????????????????????????
	
	//?????´????±±???????????°???????????¬???????????????
	vector<Mount>::iterator summit = max_element(mountList.begin(), mountList.end(), Comp );
	
	//????????°???????????´????±?????????????????????¨??????????±??????¢???????±???????
	vector<int> rightPondList = (getRightPonds( summit, mountList.end(), heightList ));
	//???????±??????????			//	//????????°??????????????????????????¨???????±??????¢???????±???????????????¢??°
	//int?????±???vector???

	//??¨???????????????????±±??????????????????
	vector<Mount> leftmountList(mountList.begin(), summit+1) ;
	reverse(leftmountList.begin(), leftmountList.end());
	
	//?????´????±???§??????????????????
	vector<int> leftPondList = (getLeftPonds(leftmountList.begin(), leftmountList.end(), heightList));
	reverse( leftPondList.begin(), leftPondList.end()); 

	leftPondList.insert(leftPondList.end(),rightPondList.begin(),rightPondList.end() );

//-----???????????????-------------------------------------------------
	//??¨???????±????????¨???¢???????±?????????¢??°
	int pondSum = getPondSum( leftPondList );
	cout << pondSum << endl;
	
	//?±?????????°
	cout << leftPondList.size()<< " ";
	
	//??¨???????±??????¢????????????????????????
	for(int i = 0;  i < leftPondList.size() ; i++ ){
		cout <<  leftPondList[i] ;
		if( i !=  (leftPondList.size()-1) ){
			cout << " ";
		}
	}
	cout << endl;
//------------------------------------------------------
	return 0;
}	//???????????????

Compiler output:
a.cc: In function 'std::vector<int> getRightPonds(std::vector<Mount>::iterator, std::vector<Mount>::iterator, std::vector<int>)':
a.cc:178:26: error: 'max_element' was not declared in this scope
  178 |                 summit = max_element(summit+1, end, Comp );
      |                          ^~~~~~~~~~~
a.cc: In function 'std::vector<int> getLeftPonds(std::vector<Mount>::iterator, std::vector<Mount>::iterator, std::vector<int>)':
a.cc:193:18: error: 'max_element' was not declared in this scope
  193 |         summit = max_element(summit+1, end, Comp);
      |                  ^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:225:42: error: 'max_element' was not declared in this scope
  225 |         vector<Mount>::iterator summit = max_element(mountList.begin(), mountList.end(), Comp );
      |                                          ^~~~~~~~~~~
a.cc:234:9: error: 'reverse' was not declared in this scope
  234 |         reverse(leftmountList.begin(), leftmountList.end());
      |         ^~~~~~~