KGS math club/solution 11 9
Each searches up the hats, level by level, until he sees a level at which all the other dwarfs are wearing blue hats. He specifies this level.
This succeeds with probability 1/(N+1). I have heard that better solutions are possible, but no-one has offered me one.