The right answer for n=4 is k=3 3 3 1 2 3 3 1 2 4 2 3 4 Previous answer << 4 3 1 2 3 3 1 2 4 3 1 3 4 3 2 3 4 >> is wrong because the 1st colour is used 3 times.
Because my proposed answer is k=3, so the answer in problemset is right. Authors did not use the 4th colour because they can make 3 flags with 3 colours. It is only their choice.