Here is what you can do with the latest version of nicematrix ( ≥ v. 6.22 2023-08-14).
\documentclass{article}
\usepackage{nicematrix,tikz}
\NiceMatrixOptions
{
code-for-first-row = \color{red} ,
code-for-last-col = \color{red} ,
xdots/horizontal-labels
}
\begin{document}
$\begin{pNiceArray}{ccc|cc}[first-row,last-col,xdots/line-style=<->,margin=2pt]
\Hdotsfor{3}^{3} & \Hdotsfor{2}^{2} \
1 & 1 & 1 & 1 & 1 & \Vdotsfor{3}^{3}\
1 & 1 & 1 & 1 & 1 \
1 & 1 & 1 & 1 & 1 \
\hline
1 & 1 & 1 & 1 & 1 & \Vdotsfor{2}^{2}\
1 & 1 & 1 & 1 & 1 \
\end{pNiceArray}$
\end{document}
You need several compilations (because nicematrix uses PGF/Tikz nodes).

\documentclassand ending with\end{document}. - Related: https://tex.stackexchange.com/a/32981/124842, https://tex.stackexchange.com/q/40535/124842 – Bobyandbob Oct 15 '17 at 11:01