Symmetry and asymmetry of minimizers of a class of noncoercive functionals