当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1869:Test

题目描述
A vocational preference test, unlike an aptitude test, seeks to identify careers that the candidate might find satisfying. Based on the answers to a slew of seemingly inane multiple-choice questions like the one below, the test determines which occupations suit the candidate's personality.
   Which would you rather spend an afternoon doing?


(a) feeding chickens
(b) driving a race car
(c) watching The Simpsons on TV
(d) suntanning
(e) building a dog house

Each question asks the candidate to express a preference from among five activities, selected from a common larger set. That is, activities like feeding chickens or suntanning are likely to appear in several different questions.
If a candidate answers A in a question containing A, B, C, D, E as alternatives, this choice indicates a preference for A over each of B, C, D, E. Also, if one answer indicates a preference for X over Y and one or more other answers indicate a preference for Y over Z, the combined set of answers indicates a preference for X over Z.

The candidate may provide contradictory answers; that is, the answers may indicate a preference for X over Y and also for Y over X. These contradictions indicate inconsistency, a personalitiy attribute that may suggest a career in politics or used auto sales.

Given a set of answers to a vocational preference test, you are to partition the activities into the minimal number of sets such that, for each pair within a given set, the answers indicate a contradictory preference.
输入解释
The input contains several test cases followed by a line containing 0. Each case begins with n, the number of questions in the test. n lines follow, each containing the names of five distinct activities, followed by the candidate's answer - one of the five alternatives. Each activity is named by a single upper case letter.
输出解释
For each test case, output the sets, one per line. Output the elements of each set in alphabetical order, and output the sets in alphabetical order by their least element. The sets should together contain exactly the set of activities that appear in the input. Leave an empty line between test cases.
输入样例
4
A B C D E C
F C H I J J
K B H I F I
K C E B J K
0
输出样例
A
B
C
D
E
F
H
I J K

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1869

最后修改于 2020-10-29T06:16:15+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 30000