Wedding High Table

We are planning the set-up of the guests for the celebration dinner of
the wedding of our beloved friends Gride and Broom. We want to make sure
that, at the main table where they will sit, everyone knows everyone
else. Also, we want to have as many guests as possible in that main
table while obeying that condition. How many guests are we able to
accomodate there?

Input

The input tells us who knows whom by listing all acquaintances: first
comes a line with a non-negative integer m, the m lines follow, each
containing two names and meaning that these two guests know each other.
Names are made up of upper- or lower-case letters and are separated by
one space. (Gride and Broom do not appear there; there is no need since
they know everyone in their wedding.)

Output

The output is the number of guests (not counting the happy pair) that
make up the largest possible main table, written in a line, and followed
by the names, in string order, of the guests that configure that largest
table, one per line.

Observation

The time spent by your solution will be compared to that of a (not
particularly smart) backtracking. However, too naïve algorithmics incur
a serious risk of not being accepted due to slowness.

Problem information

Author: José Luis Balcázar

Generation: 2026-01-25T19:39:40.768Z

© Jutge.org, 2006–2026.
https://jutge.org
