Another hat puzzle (One of the previous hat puzzles was this)
Source: Stanford student Haidong Wang
A teacher puts on 10 hats of either red or blue on 10 students. Each one can see the hats on all other 9 students, but not his own. The teacher tells them that at least one of the hat is blue. The teacher asks each one to write down the color of his hat if he's sure about it, or he can write down "don't know" if he can't deduce its color. Everyone reveals their answer at the same time and all of them write "don't know". The second day, they gather again and the teacher puts on the same hats. Each one has to think about the color of his hat again. This time, still no one can figure out his hat color (i.e. everyone writes down "don't know"). This game repeats in the same way on third day, fourth day, ..., until the ninth day. Still no one figures out. However, on the tenth day, everyone writes down the correct color of his hat. So explain what happened? And what's the color they wrote down? Assume throughout the 10 days, those students do not communicate with each other. And also assume everyone is smart and knows everyone else is smart, and so on.
Update (11/12/09): Solution posted by viki in comments!!