Based on the other examples of our book, I can imagine three ways to say this:
Are they all correct and do they have exactly the same meaning?
The 1st one and 2nd one are both correct, and have almost same meaning; but different emphasis.
The emphasis of the 1st one is the lasting time, i.e.
Q: 你跳舞跳了多长时间？ => The question is focused on how long A: 我跳舞跳了三个小时。
The emphasis of the 2nd one is what (sb. do). e.g.
Q: 你下午做什么去了？ => The question is focused on what you did A: 我跳了三个小时的舞。
The 3rd one is wrong. At the end of the sentence a noun is expected; which should be the object of the preceding verb, i.e.
It is a [topic]+[comment/opinion] structure.
[我跳舞](I dance) is the topic.
[跳了三個小時] is the comment that provides more details on the topic.
It is a [subject]+ [verb] + [object] structure.
[我] (I) is the subject.
[跳了] (danced) is the verb.
[舞] (dance) is the object.
[三個小時的] (three hours of) is the relative clause for the object that makes [三個小時的舞] as a whole, the object.
Both sentences above are grammatically correct and have the same meaning.
This one is grammatically incorrect. The second 跳 is not needed. You don't need two identical verbs for the same object.