atcoder#KEYENCE2021D. Choosing Up Sides
Choosing Up Sides
Score : points
Problem Statement
Let be a positive integer. Consider a competition where two teams, each with players, play against each other.
We have players numbered through . Coach Snuke can do the following operation any number of times: separate the players into two teams A and B, each with players, and make them play against each other.
He wants to do this operation one or more times so that both of the following conditions are satisfied:
- there exists an integer such that, for every such that , Player and Player have belonged to the same team exactly times.
- there exists an integer such that, for every such that , Player and Player have belonged to different teams exactly times.
We can prove that there exist sequences of operations that achieve Snuke's objective. Among those sequences, present one sequence with the minimum possible number of operations.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print a sequence of operations in the format below:
Here, represents the length of the sequence, and represents the division into teams in the -th operation.
should be a string of length consisting of A
and B
. In the -th operation, if Player belongs to Team A, the -th character of should be A
; if Player belongs to Team B, the -th character of should be B
. Note that A
and B
each must occur exactly times in each .
Your output will be accepted when is the minimum possible length of a sequence of operations that achieves the objective, and the sequence actually achieves the objective.
1
1
AB
- We can satisfy the objective with one operation.
- Note that we must do at least one operation.