The variational preparation of complex quantum states using the quantum approximate optimization algorithm (QAOA) is of fundamental interest, and becomes a promising application of quantum computers. Here, we systematically study the performance of QAOA for preparing ground states of target Hamiltonians near the critical points of their quantum phase transitions, and generating Greenberger-Horne-Zeilinger (GHZ) states. We reveal that the performance of QAOA is related to the translational invariance of the target Hamiltonian: Without the translational symmetry, for instance due to the open boundary condition (OBC) or randomness in the system, the QAOA becomes less efficient. We then propose a generalized QAOA assisted by the parameterized resource Hamiltonian (PRH-QAOA), to achieve a better performance. In addition, based on the PRH-QAOA, we design a low-depth quantum circuit beyond one-dimensional geometry, to generate GHZ states with perfect fidelity. The experimental realization of the proposed scheme for generating GHZ states on Rydberg-dressing atoms is discussed. Our work paves the way for performing QAOA on programmable quantum processors without translational symmetry, especially for recently developed two-dimensional quantum processors with OBC.