We use 1 kpc resolution cosmological AMR simulations of a Virgo-like galaxy cluster to investigate the effect of feedback from supermassive black holes (SMBH) on the mass distribution of dark matter, gas and stars. We compared three different models: (i) a standard galaxy formation model featuring gas cooling, star formation and supernovae feedback, (ii) a quenching model for which star formation is artificially suppressed in massive halos and finally (iii) the recently proposed AGN feedback model of Booth & Schaye (2009). Without AGN feedback (even in the quenching case), our simulated cluster suffers from a strong overcooling problem, with a stellar mass fraction significantly above observed values in M87. The baryon distribution is highly concentrated, resulting in a strong adiabatic contraction (AC) of dark matter. With AGN feedback, on the contrary, the stellar mass in the bright central galaxy (BCG) lies below observational estimates and the overcooling problem disappears. The stellar mass of the BCG is seen to increase with increasing mass resolution, suggesting that our stellar masses converges to the correct value from below. The gas and total mass distributions are in striking agreement with observations. We also find a slight deficit (~10%) of baryons at the virial radius, due to the effect of AGN-driven shock waves pushing gas to Mpc scales and beyond. This baryon deficit results in a slight adiabatic expansion of the dark matter distribution, that can be explained quantitatively by AC theory.