QOJ.ac

QOJ

Time Limit: 10 s - 20 s Memory Limit: 1024 MB Total points: 30

#5974. 双语

Statistics

Elliot 的父母在家里对他讲法语和英语。他听过很多单词,但并不总是清楚哪些词来自哪种语言!Elliot 确定其中一个句子是英语,另一个句子是法语,还有一些句子可能是英语也可能是法语。如果一个单词出现在英语句子中,它必须是一个英语单词。如果一个单词出现在法语句子中,它必须是一个法语单词。

考虑 Elliot 听到的所有句子,他听到的单词中,必须既是英语单词又是法语单词的单词数量最少是多少?

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例的第一行包含一个整数 $N$。接下来有 $N$ 行,每行包含一系列以空格分隔的“单词”。每个“单词”仅由小写字母 a-z 组成。这 $N$ 行中的第一行是英语“句子”,第二行是法语“句子”。其余的句子可能是英语,也可能是法语。(注意,这些“单词”和“句子”不保证在任何真实语言中有效。)

输出格式

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是测试用例编号(从 1 开始),$y$ 是 Elliot 听到的单词中,必须既是英语单词又是法语单词的最小数量。

数据范围

内存限制:1 GB。

$1 \le T \le 25$。

每个单词不超过 10 个字符。

两个“已知”句子每句不超过 1000 个单词。

“未知”句子每句不超过 10 个单词。

小数据集(6 分)

时间限制:10 秒。

$2 \le N \le 20$。

大数据集(24 分)

时间限制:20 秒。

$2 \le N \le 200$。

样例

样例输入 1

4
2
he loves to eat baguettes
il aime manger des baguettes
4
a b c d e
f g h i j
a b c i j
f g h d e
4
he drove into a cul de sac
elle a conduit sa voiture
il a conduit dans un cul de sac
il mange pendant que il conduit sa voiture
6
adieu joie de vivre je ne regrette rien
adieu joie de vivre je ne regrette rien
a b c d e
f g h i j
a b c i j
f g h d e

样例输出 1

Case #1: 1
Case #2: 4
Case #3: 3
Case #4: 8

说明

在 Case #1 中,Elliot 确定第一个句子是英语,第二个是法语,因此没有歧义;唯一必须既是英语又是法语的单词是 "baguettes"。

在 Case #2 中,最后两个句子可能是:英语-英语、英语-法语、法语-英语或法语-法语。这几种可能性中,使两种语言共有单词数量最少的情况是第二种;该集合最终为 d, e, i 和 j。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.