The woman who wrongfully accused four men of rape at Hofstra University will have to get mental health treatment and do 250 hours of community service — or else face criminal charges, authorities announced this afternoon.

Nassau County DA Kathleen Rice said her office has imposed those conditions on 18-year-old Hofstra freshman Danmell Ndonye after she said she was raped earlier this month.

“There exists no perfect solution to this case, only our best attempt at holding her accountable while encouraging real victims to come forward and accusers to tell the truth so that we can avoid incarcerating an innocent person for even one minute,” said Rice.

“This agreement is the only way we guarantee that this woman gets the help that she needs and is held publicly accountable for what she’s done to our community.”

The deal ends a nearly two-week probe that began on Sept. 13 when Ndonye accused five men of raping her in a campus dorm bathroom.

Within days, Ndonye admitted to prosecutors that the events in the bathroom were “consensual and that she had lied to police,” the Nassau County DA’s office said in a statement today.

The men were immediately released and the charges filed against them immediately dropped.

In their statement, the DA said Ndonye admitted to lying to police and to engaging in “consensual sexual activity with four men in the dormitory bathroom.”

As part of the deal, Ndonye has agreed to attend a year-long psychiatric program and 250 hours of community service.

The girl said she did not engage in any sexual activity with a fifth man, Hofstra student Rondell Bedward, the DA said.

One of the men previously accused of rape, Kevin Taveras, told The Post, “I don’t wish ill will on anyone, but I think it would be a shame if she walked away from it. She should at least go through the system and spend a few days in jail. We spent four days in jail.”