Here is the solution: Just imagine to be the student who has the solution first:
You see the other two students - which are the possibilities?
1. both wear a black hat
In this case you know you must wear a red hat and you say it immediately.
2. one of them wears a red hat, the second one wears a black hat.
Now you can wear either black or red but if you wear a black hat the guy with the red hat would say "red" immediately because he would see two black hats and would know immediately. When he does not say "I wear a red hat" you know that he does not see 2 black hats and you wear a red hat. This cannot take 10 minutes because the other two are very intelligent and if they do not say anything, you know right away that you wear a red hat.
3. both wear red hats.
Now you can again wear a black or red hat but if you wear a black hat, the other two see a black and a red hat each and are in the situation Nr. 2. They would guess pretty soon that they wear red because the other one is silent. Since none of the two says he wears red, it's obvious that you all wear red hats and the first who has thought this to the end wins.
Thread