1541_GuardianofDecency

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

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

Pro.ID

1541

Title

Guardian of Decency

Title链接

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

AC

10

Submit

17

Ratio

58.82%

时间&空间限制

  • Time Limit: 6000/2000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that some of them might become couples. While you can never exclude this possibility, he has made some rules that he thinks indicates a low probability two persons will become a couple: 

    • Their height differs by more than 40 cm.
    • They are of the same sex.
    • Their preferred music style is different.
    • Their favourite sport is the same (they are likely to be fans of different teams and that would result in fighting). 

     So, for any two persons that he brings on the excursion, they must satisfy at least one of the requirements above. Help him find the maximum number of persons he can take, given their vital information.

    输入

    The first line of the input consists of an integer T ≤ 100 giving the number of test cases. The first line of each test case consists of an integer N ≤ 500 giving the number of pupils. Next there will be one line for each pupil consisting of four space-separated data items: 

    • an integer h giving the height in cm;
    • a character 'F' for female or 'M' for male;
    • a string describing the preferred music style;
    • a string with the name of the favourite sport.

    No string in the input will contain more than 100 characters, nor will any string contain any whitespace.

    输出

    Description

    Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that some of them might become couples. While you can never exclude this possibility, he has made some rules that he thinks indicates a low probability two persons will become a couple: 

    • Their height differs by more than 40 cm.
    • They are of the same sex.
    • Their preferred music style is different.
    • Their favourite sport is the same (they are likely to be fans of different teams and that would result in fighting). 

     So, for any two persons that he brings on the excursion, they must satisfy at least one of the requirements above. Help him find the maximum number of persons he can take, given their vital information.

    Input

    The first line of the input consists of an integer T ≤ 100 giving the number of test cases. The first line of each test case consists of an integer N ≤ 500 giving the number of pupils. Next there will be one line for each pupil consisting of four space-separated data items: 

    • an integer h giving the height in cm;
    • a character 'F' for female or 'M' for male;
    • a string describing the preferred music style;
    • a string with the name of the favourite sport.

    No string in the input will contain more than 100 characters, nor will any string contain any whitespace.

    Output
    For each test case in the input there should be one line with an integer giving the maximum number of eligible pupils.
    Sample Input
    2
    4
    35 M classicism programming
    0 M baroque skiing
    43 M baroque chess
    30 F baroque soccer
    8
    27 M romance programming
    194 F baroque programming
    67 M baroque ping-pong
    51 M classicism programming
    80 M classicism Paintball
    35 M baroque ping-pong
    39 F romance ping-pong
    110 M romance Paintball
    Sample Output
    3
    7
    Source

    样例输入

    2
    4
    35 M classicism programming
    0 M baroque skiing
    43 M baroque chess
    30 F baroque soccer
    8
    27 M romance programming
    194 F baroque programming
    67 M baroque ping-pong
    51 M classicism programming
    80 M classicism Paintball
    35 M baroque ping-pong
    39 F romance ping-pong
    110 M romance Paintball

    样例输出

    3
    7

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部