The two ways of relating what a person has said are 1)direct and 2)indirect (reported speech).In direct speech, the original speaker's exact words are repeated. Direct speech is found in plays and quotations. In indirect/reported speech, the exact meaning is expressed but not necessarily using the original speaker's exact words. Pronouns and possessive adjectives usually change from first or second person to the third person except when the speaker is reporting his own words. Sometimes a noun can be inserted to avoid doubt.
Option D is correct as if is used,can is changed to could, we to they, to which is used to join the two statements, and is is changed to was .
Options A,B, and C are wrong as if is not used, can can't be used, and could they cannot be used respectively.
The correct answer is D)Sam asked Sue if they could go for a swim to which Sue replied it was a good idea.