Disclosed are compounds having formulae I and II or pharmaceutically acceptable salts or hydrates thereof, a preparation method thereof and pharmaceutical compositions thereof. The compounds having formulae I and II possesses an isocitrate dehydrogenase 2 (IDH2) inhibitory activity and are capable of treating IDH2 mutation-induced cancers.