포럼
문제 ICPC00262

E. Eeny Meeny

설명

"Eeny meeny miny moe" is a well-known nursery rhyme in English, used (among other things) by kids to "randomly" select members of a team. It exists in many variations, one of which goes like this: quote Eeny, meeny, miny, moe,

Catch a tiger by the toe.

If he hollers, let him go,

Eeny, meeny, miny, moe. quote Similar verses exist in most languages, such as "Ulle dulle dof" in Finnish, "Akka bakka bonka rakka" in Norwegian, and "Ole dole doff" in Swedish.

Two teams are to be selected for a game and the rhyme is used to select one kid for a team at a time, alternating between the two teams, until all kids have been selected. The kids are standing in a circle. In each selection round we start counting the kids in clockwise order around the circle, skipping one kid for every word in the rhyme, until the last word. The kid matching the last word is chosen for the current team and then the next round starts. In all rounds but the first, the counting starts at the next remaining kid (in clockwise order) after the one that was selected in the previous round. See Figure for an example.

Given such a rhyme, and a group of kids, can you tell which kids will be in which team?

제약
입력 형식

The first line of input contains the rhyme, consisting of a list of words separated by spaces. The second line of input contains an integer \(n\) (\(1 \le n \le 100\)), the number of kids. Then follow the names of the kids, one per line. The kids are given in clockwise order and the first kid listed is the one at which counting starts in the first round.

All words and names consist only of upper and lower case letters 'A'-'Z' and 'a'-'z'. No input line is empty or longer than \(100\) characters (excluding the newline character at the end of the line).

출력 형식

Output the two teams, starting with the one whose first member is chosen first. For each team, output the number of kids in the team, followed by the names of the kids in the team, in the same order as they were chosen for the team.

예제 1
입력
eeny meeny miny
4
Kalle
Lisa
Alvar
Rakel
출력
2
Alvar
Rakel
2
Lisa
Kalle
예제 2
입력
Every Other
3
a
b
c
출력
2
b
c
1
a
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2019

평가 및 의견

E. Eeny Meeny

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

E. Eeny Meeny

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8