Let $p$ be a prime number and $(G,\cdot)$ be a group with $p^3$ elements. We denote by $\operatorname{C}(x)$ the centraliser of $x\in G$. If $|\operatorname{Z}(G)|=p$, then find the cardinal of the set $\{\operatorname{C}(x)\mid x\in G\}$.
I observed that for any $x\in G\setminus \operatorname{Z}(G)$ we have that $|\operatorname{C}(x)|=p^2$ by considering the fact that $\operatorname{Z}(G)$ is a proper subgroup of $\operatorname{C}(x)$ (this implies that $p<|\operatorname{C}(x)|<p^3$ and since $p | |\operatorname{C}(x)|$ the result follows). After this I got stuck. I also tried to apply the class equation, but this only yielded (in a more complicated way) that $|\operatorname{C}(x)|=p^2$ again.
For $x\in G-Z(G)$ you know that $C(x)$ contains $p^2-p$ elements outside $Z(G)$. Any two such centralisers are either identical or intersect in $Z(G)$ and every element of $G$ is in its own centraliser.
Let there be $N$ such centralisers then, counting elements in $G$, $$N(p^2-p)+p=p^3$$ and so $N=p+1$. Since we also have $G$ itself, as the centraliser of any element in $Z(G)$, there are $p+2$ centralisers in total.