Anti-Sorting Game
시간 제한1.5초메모리 제한2048 MB
두 플레이어가 정렬되지 않은 이진 문자열의 부분 수열을 번갈아 정렬하고, 문자열을 정렬시킨 쪽이 지는 게임에서, 선공 또는 후공을 정해 이기는 수를 대화형으로 둔다.
문제
This is an interactive problem.
Busy Beaver and Lazy Lemur are playing a game on a binary string that is initially not sorted. In this game, they take turns choosing some subsequence1 that isn't sorted, and sort it in place. Formally, they select indices such that the string is not sorted, and sort only these characters of the original string.
It can be shown that no matter how the two players move, the string will become sorted after a finite number of turns. When this happens, the player who made the final move loses, and the other player wins.
Busy Beaver needs your help to beat Lazy Lemur. Given the starting string, determine whether or not Busy Beaver should choose to go first or second, then make a series of moves that wins against the judge.
1A sequence is a subsequence of a sequence if can be obtained from by the deletion of several (possibly, zero or all) elements.