Write a program to maintain basic information for the gossip
magazines: who is a couple of who. There are two kinds of orders:
“info” and “affair”
.
The first asks for a list of all the information at that moment. The
second indicates that
and
are a couple now. If some person
was a couple of
or a couple of
,
then
becomes single.
Input consists of several orders. For every “affair”
order, both
and
are words made up of only lowercase letters, such that
and
are different, and such that
and
do not have an affair at that moment.
Print as many lists as “info” orders, finishing each
with a line with 10 dashes. Print the couples in alphabetical order, and
also the couples among them. Print the alone people in alphabetical
order as well.
In the private test cases, most orders are of the
“affair” kind.
Input
affair gerard shakira info affair sara iker info affair gerard sara info affair iker cristiano info
Output
COUPLES: gerard shakira ALONE: ---------- COUPLES: gerard shakira iker sara ALONE: ---------- COUPLES: gerard sara ALONE: iker shakira ---------- COUPLES: cristiano iker gerard sara ALONE: shakira ----------
Input
info affair ba a affair b ab affair aab ac info affair ac b affair b ab info
Output
COUPLES: ALONE: ---------- COUPLES: a ba aab ac ab b ALONE: ---------- COUPLES: a ba ab b ALONE: aab ac ----------