• [1451] Elise

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Elise is the Spider Queen. She has a skill, Spider Form(蜘蛛形态).

    When she transformed to the spider, there will be some small spiders around her.

    But she has a problem - the small spiders will have infighting because of less common interest. So Elise decided to train their interesting.

    At least, they must have common interest no matter directly or indirectly.

    How to train theirs interest in least cost? We assume that train a interest for a spider cost 1 strength and there are at most 100 interests in total.

  • 输入
  • This problem contains several cases.
    The first line of each case is an integer N (1 ≤ N ≤ 100), indicates the number of spiders.
    Then N lines followed.
    The ith line contains an integer Ti (0 ≤ Ti ≤ 100) that indicates the number of this spider's interest and Ti strings indicate the interests. You can assume there are only lowercase letters in the strings and no longer than 20.
  • 输出
  • For each case, you should output the least cost.
  • 样例输入
  • 5
    1 kill
    1 kill
    2 sleep sing
    2 sing fart
    1 fart
  • 样例输出
  • 1
  • 提示
  • In this case, the spider 1 or 2 just need to learn to sleep or sing or fart. So it's 1.
    
  • 来源
  • XadillaX
  • 操作

显示春菜