Logo
(追記) (追記ここまで)

6948번 - Subsets 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB82453355.932%

문제

In this problem, you will write a program to find the minimal solution to a set of set inequalities. A set inequality has the format X contains S where $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$.

The first line of input specifies the number of set inequalities ($N$). The next $N$ lines each contain one set inequality. 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.

입력

출력

제한

예제 입력 1

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

예제 출력 1

A = {c,d}
B = {d}
F = {c,d,z}
Q = {}
R = {}
X = {x}
Y = {x}

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2000 > CCO 2000 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /