#abc312h. Ex - snukesnuke
Ex - snukesnuke
Score : points
问题描述
高桥打算为 个人(编号为 1,…,N)确定他们的昵称。
第 个人希望得到的昵称为 。为了避免给多人分配相同的昵称,他将按照以下方式决定每个人的昵称:
- 对于 按顺序执行以下操作:
- 将变量 初始化为 。
- 当 的第 次重复作为某人的昵称时,不断将 加一。
- 将第 个人的昵称设为 的第 次重复。
请在确定这 个人的昵称后,找出 的值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi is going to decide nicknames of people, person .
Person wants a nickname . To avoid giving the same nickname to multiple people, he is going to decide their nicknames as follows:
- For each in order, decide person 's nickname as follows:
- Initialize a variable with .
- Repeatedly increment by one while the -time repetition of is someone's nickname.
- Let person 's nickname be the -time repetition of .
Find , and after deciding nicknames of the people.
Constraints
- is a string of length at least consisting of lowercase English letters.
- The sum of lengths of is at most .
Input
The input is given from Standard Input in the following format:
Output
Print , and resulting from deciding the nicknames of the people by the procedure in the problem statement.
Sample Input 1
3
snuke
snuke
rng
Sample Output 1
1 2 1
- First, he decides person 's nickname.
- Let .
- The -time repetition of is
snuke
, which is nobody's nickname, so person 's nickname is set tosnuke
.
- Next, he decides person 's nickname.
- Let .
- The -time repetition of is
snuke
, which is already a nickname of person , so increment by one to make it . - The -time repetition of is
snukesnuke
, which is nobody's nickname, so person 's nickname is set tosnukesnuke
.
- Finally, he decides person 's nickname.
- Let .
- The -time repetition of is
rng
, which is nobody's nickname, so person 's nickname is set torng
.
Thus, , , and result in , , and , respectively.
Sample Input 2
4
aa
a
a
aaa
Sample Output 2
1 1 3 2
- Person 's nickname is set to
aa
. - Person 's nickname is set to
a
. - Person 's nickname is set to
aaa
, becausea
andaa
are already nicknames of someone else. - Person 's nickname is set to
aaaaaa
, becauseaaa
is already a nickname of someone else.
Sample Input 3
5
x
x
x
x
x
Sample Output 3
1 2 3 4 5
update @ 2024/3/10 08:54:29