Fortune Telling 3
시간 제한6초메모리 제한2048 MB
안나가 900개의 비트를 하나씩 보며 각 카드를 테이블에 끼워 넣거나 버릴 수 있고, 브루노는 마지막 카드 배열만 보고 1의 총개수를 알아내야 한다.
문제
Anna and Bruno like fortune-telling and enjoy playing various styles of fortune-telling together. Today, they will play fortune-telling using cards, which is described below. They will play it for times.
-
They prepare many cards with or written on each one, shuffle them, and pile them up on the deck.
-
Anna draws () cards from the deck, one at a time. Anna and Bruno know the value of . Every time she draws a card, she decides whether to discard the card or put the card on the table.
- If she selects to put the card on the table, she inserts the card into the sequence of cards on the table.
- More formally, when there are l cards on the table, she designates a non-negative integer () and puts the card immediately right to the -th leftmost card on the table. In the case of , she puts the card on the leftmost of the sequence of cards on the table.
-
The procedure for Anna finishes when she draws and processes cards. The result of the fortune-telling is the number of cards with among the cards.
-
After Anna finishes her procedure, Bruno sees the sequence of cards on the table. Using the information, he needs to guess the result of the fortune-telling. If he guesses correctly, the fortune-telling is a success.
The fortune-telling is considered more proficient when fewer cards are on the table. Write a program to implement Anna’s and Bruno’s strategies to succeed in all fortune tellings. In this task, the fewer cards Anna puts on the table, the higher the score will be.
제한
All the input data satisfy the following conditions.
- .
- .
- is either or (, ).
예제
이 문제는 공개된 예제가 없습니다.