A group of n people meet, and agree to play as a team in a game whose rules are explained to them. They are then allowed to discuss strategy. After the strategy session, an adversary puts red or blue hats on everyone's head; from this point on, no communication is allowed between the players. Each person can see the color of all hats but their own. After exactly one minute, the players simultaneously predict their hat color by sending email saying either "my hat is red" or "my hat is blue." The team wins if the n emailed statements are either all true or all false.
Devise a strategy that guarantees that the team wins, no matter how the adversary chooses to place the hats.
(extra credit) Consider the same situation, except that the goal of the group is to maximize the number of correct answers, assuming that the adversary knows exactly what strategy every member of the group is using. If each member of the group guesses red or blue with equal probability (1/2), then the expected number of correct answers will be n/2, no matter how the adversary arranges the hats. Is there a strategy (either deterministic or randomized) that does better than n/2?