Do anyone have a clue about the below problem:
A set of n persons with a distinct hats tagged accordingly by $1,...,n$ leave their hats in a room and leave the room. A naughty boy then take the hats and permutes them adversarially into n closed boxes numbered from $1$ to $n$, each hat in a distinct box, and closes the boxes. A standbyer that is in the room sees all this and records all hats placing. With a good will, but limited ability, all he is allowed to do is to open only two boxes and exchange the hats between them. This is done just once. Then the standbyer goes away and does not communicate with any person. Suppose the $n$ persons and the standbyer prepare for such situation, what should the standbyer do so that every person that might come in the room will find his hat after opening at most $n=2$ boxes (worst case, deterministic).