She studied hard, but failed the exam.

Literal

She [topic-は] with-all-one's-might studied [but-が], exam [for-に] failed.

A wistful inversion: even with 一生懸命 effort, the result didn't follow. The clause-final が serves as a soft 'but,' setting up a contrast across two clauses. 不合格する is mildly non-standard — 不合格 is properly a noun ('non-passing / failure'), and the standard verbal form is 不合格になる ('become a non-pass') or 試験に落ちる ('fall on the exam'). The form 不合格する appears in some contexts but jars slightly; treat it as the writer's choice for compactness.