Solution (source code)

= Solution

The appropriate <Poincare-Wirtinger inequality>, with no zero-boundary assumption, is
$$
\boxed{\|u-u_\Omega\|_{L^p(\Omega)}
\leq C_{\Omega,p}\|\nabla u\|_{L^p(\Omega)},\qquad
u_\Omega=\frac1{|\Omega|}\int_\Omega u,\quad1\leq p<n.}
$$
Assume $\Omega$ is nonempty, bounded, connected and has the stated cone property. If this failed, after subtracting the mean and normalizing there would be $u_j\in W^{1,p}(\Omega)$ with
$$
(u_j)_\Omega=0,\qquad \|u_j\|_p=1,\qquad \|\nabla u_j\|_p\longrightarrow0.
$$
The sequence is bounded in $W^{1,p}$. By the permitted <Rellich-Kondrachov compactness theorem>, a subsequence converges strongly in $L^p$ to $u$. For every compactly supported test function, integration by parts and these two convergences show that each <distributional derivative> of $u$ is zero. A <function with zero weak gradient> is constant on a connected open set: mollification makes it locally constant, and connectedness identifies the local constants.

Convergence in $L^p$ on a finite-measure set also preserves the integral, so $u_\Omega=0$ and the constant is zero. But strong convergence preserves $\|u\|_p=1$, a contradiction. This proves the inequality; connectedness prevents different constants on separate components.