This study designs a piecewise homogeneous dielectric structure with parity-time (PT) symmetry that realizes the unidirectional invisibility of a perfect electric conductor in two dimensions. We apply topology optimization and design a PT-symmetric material that minimizes the total scattering cross section for a given plane wave to achieve unidirectional invisibility. A rigorous mode-matching finite element method is used to perform all computations. The designed PT-symmetric structure suppressed plane-wave scattering by approximately 99% for the given incident direction, whereas the reversed incident wave experienced 83 times larger scattering intensity. The proposed method provides a novel approach, to the best of our knowledge, to promote various applications of PT symmetry.