Anti-Sorting Game

시간 제한1.5초메모리 제한2048 MB

요약
두 플레이어가 정렬되지 않은 이진 문자열의 부분 수열을 번갈아 정렬하고, 문자열을 정렬시킨 쪽이 지는 게임에서, 선공 또는 후공을 정해 이기는 수를 대화형으로 둔다.
난이도

어려움10점 중 8점

유형
게임 이론, 그리디, 구현
정답자
아직 제출이 없습니다

문제

This is an interactive problem.

Busy Beaver and Lazy Lemur are playing a game on a binary string ss 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 b_1<b_2<⋯<b_kb\_1 < b\_2 < \dots < b\_k such that the string s_b_1s_b_2…s_b_ks\_{b\_1}s\_{b\_2}\dots s\_{b\_k} 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 aa is a subsequence of a sequence bb if aa can be obtained from bb by the deletion of several (possibly, zero or all) elements.

예제1

  1. 예제 1

    입력
    3
    100
    
    
    001
    0101
    
    0011
    1100
    
    
    0110
    
    0011
    
    예상 출력
    
    
    First
    2 1 2
    
    
    Second
    
    
    First
    2 2 3
    
    3 1 3 4