CF114B.PFAST Inc.

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

When little Petya grew up and entered the university, he started to take part in АСМ contests. Later he realized that he doesn't like how the АСМ contests are organised: the team could only have three members (and he couldn't take all his friends to the competitions and distribute the tasks between the team members efficiently), so he decided to organize his own contests PFAST Inc. — Petr and Friends Are Solving Tasks Corporation. PFAST Inc. rules allow a team to have unlimited number of members.

To make this format of contests popular he organised his own tournament. To create the team he will prepare for the contest organised by the PFAST Inc. rules, he chose several volunteers (up to 16 people) and decided to compile a team from them. Petya understands perfectly that if a team has two people that don't get on well, then the team will perform poorly. Put together a team with as many players as possible given that all players should get on well with each other.

当小彼佳长大并进入大学后,他开始参加 ACM 竞赛。后来他意识到自己并不喜欢 ACM 竞赛的组织方式:每支队伍最多只能有三名成员(因此他无法带齐所有朋友参赛,也无法在队员间高效地分配任务),于是他决定创办自己的竞赛组织——PFAST Inc.(Petr and Friends Are Solving Tasks Corporation,即“彼佳与朋友们解题公司”)。PFAST Inc. 的规则允许一支队伍拥有任意数量的成员。

为了推广这种竞赛形式,他组织了一场自己的锦标赛。为组建一支符合 PFAST Inc. 规则的参赛队伍,他招募了若干志愿者(最多 16 人),并计划从中选出一支队伍。彼佳非常清楚:如果一支队伍中存在两名彼此相处不睦的成员,那么该队伍的整体表现就会很差。请在保证所有入选队员彼此都能和睦相处的前提下,组建一支人数尽可能多的队伍。

输入格式

The first line contains two integer numbers n (1 ≤ n ≤ 16) — the number of volunteers, and m () — the number of pairs that do not get on. Next n lines contain the volunteers' names (each name is a non-empty string consisting of no more than 10 uppercase and/or lowercase Latin letters). Next m lines contain two names — the names of the volunteers who do not get on. The names in pair are separated with a single space. Each pair of volunteers who do not get on occurs exactly once. The strings are case-sensitive. All n names are distinct.

第一行包含两个整数 nn(1≤n≤161 \leq n \leq 16)——志愿者人数,以及 mm()——互不融洽的志愿者对数。接下来的 nn 行每行包含一个志愿者姓名(每个姓名为一个非空字符串,由至多 10 个大写和/或小写拉丁字母组成)。再接下来的 mm 行每行包含两个姓名——表示互不融洽的一对志愿者。同一行中的两个姓名以单个空格分隔。每一对互不融洽的志愿者恰好出现一次。字符串区分大小写。所有 nn 个姓名互不相同。

输出格式

The first output line should contain the single number k — the number of people in the sought team. Next k lines should contain the names of the sought team's participants in the lexicographical order. If there are several variants to solve the problem, print any of them. Petya might not be a member of the sought team.

第一行输出应包含一个整数 kk —— 所求团队中的人数。接下来的 kk 行应按字典序输出所求团队成员的姓名。若存在多种可行解,输出任意一种即可。Petya 不一定属于所求团队。

输入输出样例

  • 输入#1

    3 1
    Petya
    Vasya
    Masha
    Petya Vasya

    输出#1

    2
    Masha
    Petya
  • 输入#2

    3 0
    Pasha
    Lesha
    Vanya

    输出#2

    3
    Lesha
    Pasha
    Vanya

输入解题思路,AI测评打分。不知道怎么写?

首页