To get P , S , MR , and MC
for ( int i = 0 ; i < mat . size ( ) ; i ++ ) { for ( int j = 0 ; j < mat [ 0 ] . size ( ) ; j ++ ) { if ( i == j ) P . push_back ( mat [ i ] [ j ] ) ; if ( i + j == mat . size ( ) - 1 ) S . push_back ( mat [ i ] [ j ] ) ; if ( i == floor ( ( mat . size ( ) - 1 ) / 2 ) ) MR . push_back ( mat [ i ] [ j ] ) ; if ( j == floor ( ( mat . size ( ) - 1 ) / 2 ) ) MC . push_back ( mat [ i ] [ j ] ) ; } } reverse ( S . begin ( ) , S . end ( ) ) ;