Option "B" is an example of metaphor: "Her room was a pigsty." A metaphor describes an object but in a way that it isn't literally true. When using a metaphor, you are comparing things indirectly; that's why you are making use of figurative language (not literal language). In the example, "her room" is being compare with an enclosure for pigs (i.e. her room is really dirty and a mess.)
Options "A" and "C" are examples of similes which are other way of comparing two different things, but in a direct manner. The words "like" or "as" are used for similes.
Option "D": There's no comparison by neither a metaphor nor a simile; just a description of her "room" by means of a descriptive adjective.