Problem

Source: Serbia TST 2015 Problem 3

Tags: combinatorics, puzzle



We have $2015$ prisinoers.The king gives everyone a hat coloured in one of $5$ colors.Everyone sees all hats expect his own.Now,the King orders them in a line(a prisioner can see all guys behind and in front of him).The king asks the prisinoers one by one does he know the color of his hat.If he answers NO,then he is killed.If he answers YES,then answers which color is his hat,if his answers is true,he goes to freedom,if not,he is killed.All the prisinors can hear did he answer YES or NO,but if he answered YES,they don't know what did he answered(he is killed in public).They can think of a strategy before the King comes,but after that they can't comunicate.What is the largest number of prisinors we can guarentee that can survive?