#include <iostream>
#include <vector>
#include <algorithm>

template<class T>
struct array_2d : public std::vector<std::vector<T>> {
	array_2d(size_t rows, size_t cols) : std::vector<std::vector<T>>(rows, std::vector<T>(cols)) {}
};


int main() {
	size_t rows = 5, cols = 10;

	array_2d<int> a2d(rows, cols);
	
	// fill 2d-matrix
	int counter = 0;
	for(auto &c: a2d) {
		for(auto &r: c) {
			r = ++counter;
			std::cout << r << ", ";
		}
		std::cout << std::endl;
	}
	std::cout << std::endl;

	std::vector<int> min_row;
	std::vector<int> min_col = a2d[0];
	
	// min for each - row
	for(auto &c: a2d) 
		min_row.push_back( *std::min_element(c.begin(), c.end()) );

	// min for each - col
	for(auto &c: a2d) 
		std::transform(c.begin(), c.end(), min_col.begin(), min_col.begin(), 
			 [](auto v1, auto v2) { return std::min(v1, v2); } );

	for(auto &mr: min_row) std::cout << mr << ", ";
	std::cout << std::endl;

	for(auto &mc: min_col) std::cout << mc << ", ";
	std::cout << std::endl;

	return 0;
}