2000 Canadian Computing Competition, Stage 2
Day 1, Problem 1: Subsets
In this problem, you will write a program to find the minimal solution to a set of set inequalities. A set inequality has the formatwhere X may be any set name and S may be a set name or set element. If S is a set name the inequality means that X is a superset or equal to S. If S is an element the inequality means that X contains S. Sets are named A-Z and contain elements from a-z.X contains S
Input
The first line of input specifies the number of set inequalities (N). The next N lines each contain one set inequality.Output
For each set name that appears in the input, your program must determine its minimal set: the smallest set of elements that the name must take in order that all of the inequalities hold. Output, in alphabetical order, each set name followed its minimal set, with the elements in alphabetical order, in the format shown below.Sample Input
9 A contains B A contains c B contains d F contains A F contains z X contains Y Y contains X X contains x Q contains R
Sample Output
A = {c,d} B = {d} F = {c,d,z} Q = {} R = {} X = {x} Y = {x}
All Submissions
Best Solutions
Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Apr 19, 2009
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
It's quiet in here...