It is a valid sentence it just means something different :
she can't have worked - her not working must be the reason (for not doing well)
she didn't work - she didn't work after the exam because of her low mark
To me, in this example "can't have worked" carries a slightly different nuance of meaning than "didn't work." Assuming that you made an error and that "he" and "she" are referring to the same person, it seems to me that if you wanted to use "didn't" you would have to say something like:
She got a terrible mark in the exam so she evidently did not work very hard at all.
She got a terrible mark in the exam so she clearly didn't work very hard at all.