21273_UserNames

2022-5-16 18:19| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-8950586408299-Problem List-采集的数据-后羿采集器.html

Pro.ID

21273

Title

User Names

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21273

AC

1

Submit

8

Ratio

12.50%

时间&空间限制

  • Time Limit: 10000/5000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    A university's computer system assigns user names according to the following set of rules:

    1. The maximum length of a username is MAXLEN characters. (The value of MAXLEN will be specified in the input for each problem instance.)

    2. The first character of the user name is the first letter of the person's first name, converted to lower case. Ignore apostrophes and hyphens here and in Step 3.

    3. Append as many letters of the person's last name as possible (converted to lower case, if necessary), without exceeding a total of MAXLEN characters. Starting with the first letter of the last name, append these letters in the order in whch they appear in the last name.

    4. If a user name assigned on basis of Rules 1 - 3 already exists in the database, break the tie as follows: append serial numbers 1 - 9, in that order, to the username from step 3, if that can be done without exceeding the limit of MAXLEN characters in the username. Otherwise, drop the last letter before appending the serial number.

    5. If a user name assigned on basis of Rules 1 - 4 already exists in the database, break the tie as follows: append serial numbers 10 - 99, in that order, to the username from step 3, if that can be done without exceeding the limit of MAXLEN characters in the username. Otherwise, drop the last letter or the last two letters (whichever is necessary) before appending the serial number.

    6. It is assumed that the above rules will avoid ties.

    输入

    The input will contain data for a number of test cases. The first line of each test case will contain two positive integers: the number of names and the value of MAXLEN (5 ≤ MAXLEN ≤ 80). This will be followed by the list of names. Each name will consist of at most 80 characters and will begin with the first name, followed by middle names, if any, and will conclude with the last name. A single blank space will separate first, middle, and last names. Any name can contain upper and lower case letters, hyphens, and apostrophes. A last name will contain at least two letters, other names will contain at least one letter (they could be just initials). There will be no more than 200 names in each case. The last test case will be followed by a line containing two zeros for the number of names and MAXLEN.

    输出

    Description

    A university's computer system assigns user names according to the following set of rules:

    1. The maximum length of a username is MAXLEN characters. (The value of MAXLEN will be specified in the input for each problem instance.)

    2. The first character of the user name is the first letter of the person's first name, converted to lower case. Ignore apostrophes and hyphens here and in Step 3.

    3. Append as many letters of the person's last name as possible (converted to lower case, if necessary), without exceeding a total of MAXLEN characters. Starting with the first letter of the last name, append these letters in the order in whch they appear in the last name.

    4. If a user name assigned on basis of Rules 1 - 3 already exists in the database, break the tie as follows: append serial numbers 1 - 9, in that order, to the username from step 3, if that can be done without exceeding the limit of MAXLEN characters in the username. Otherwise, drop the last letter before appending the serial number.

    5. If a user name assigned on basis of Rules 1 - 4 already exists in the database, break the tie as follows: append serial numbers 10 - 99, in that order, to the username from step 3, if that can be done without exceeding the limit of MAXLEN characters in the username. Otherwise, drop the last letter or the last two letters (whichever is necessary) before appending the serial number.

    6. It is assumed that the above rules will avoid ties.

    Input

    The input will contain data for a number of test cases. The first line of each test case will contain two positive integers: the number of names and the value of MAXLEN (5 ≤ MAXLEN ≤ 80). This will be followed by the list of names. Each name will consist of at most 80 characters and will begin with the first name, followed by middle names, if any, and will conclude with the last name. A single blank space will separate first, middle, and last names. Any name can contain upper and lower case letters, hyphens, and apostrophes. A last name will contain at least two letters, other names will contain at least one letter (they could be just initials). There will be no more than 200 names in each case. The last test case will be followed by a line containing two zeros for the number of names and MAXLEN.

    Output

    For each case, the output will begin with a line containing the case number. This will be followed by the list of user names, one per line, in the same order as the corresponding names in the input.

    Sample Input

    2 6
    Jenny Ax
    Christos H Papadimitriou
    11 8
    Jean-Marie d'Arboux
    Jean-Marie A d'Arboux
    Jean-Marie B d'Arboux
    Jean-Marie C d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie F d'Arboux
    Jean-Marie G d'Arboux
    Jean-Marie H d'Arboux
    Jean-Marie I d'Arboux
    Jean-Marie J d'Arboux
    11 9
    Jean-Marie d'Arboux
    Jean-Marie A d'Arboux
    Jean-Marie B d'Arboux
    Jean-Marie C d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie F d'Arboux
    Jean-Marie G d'Arboux
    Jean-Marie H d'Arboux
    Jean-Marie I d'Arboux
    Jean-Marie J d'Arboux
    0 0

    Sample Output

    Case 1
    jax
    cpapad
    Case 2
    jdarboux
    jdarbou1
    jdarbou2
    jdarbou3
    jdarbou4
    jdarbou5
    jdarbou6
    jdarbou7
    jdarbou8
    jdarbou9
    jdarbo10
    Case 3
    jdarboux
    jdarboux1
    jdarboux2
    jdarboux3
    jdarboux4
    jdarboux5
    jdarboux6
    jdarboux7
    jdarboux8
    jdarboux9
    jdarbou10

    Source

    样例输入

    2 6
    Jenny Ax
    Christos H Papadimitriou
    11 8
    Jean-Marie d'Arboux
    Jean-Marie A d'Arboux
    Jean-Marie B d'Arboux
    Jean-Marie C d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie F d'Arboux
    Jean-Marie G d'Arboux
    Jean-Marie H d'Arboux
    Jean-Marie I d'Arboux
    Jean-Marie J d'Arboux
    11 9
    Jean-Marie d'Arboux
    Jean-Marie A d'Arboux
    Jean-Marie B d'Arboux
    Jean-Marie C d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie D d'Arboux
    Jean-Marie F d'Arboux
    Jean-Marie G d'Arboux
    Jean-Marie H d'Arboux
    Jean-Marie I d'Arboux
    Jean-Marie J d'Arboux
    0 0

    样例输出

    Case 1
    jax
    cpapad
    Case 2
    jdarboux
    jdarbou1
    jdarbou2
    jdarbou3
    jdarbou4
    jdarbou5
    jdarbou6
    jdarbou7
    jdarbou8
    jdarbou9
    jdarbo10
    Case 3
    jdarboux
    jdarboux1
    jdarboux2
    jdarboux3
    jdarboux4
    jdarboux5
    jdarboux6
    jdarboux7
    jdarboux8
    jdarboux9
    jdarbou10

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部