Antiferromagnetism, superconductivity and phase diagram in the three-band model of high-temperature cuprates