| CodeRams Practice Problem Archive |
|---|
| Finished |
You're going to a city that has a large subway system. The subway system has $$$n$$$ lines, and each line has a certain number of stations. However, some stations are "transfer stations": multiple lines go through them.
Given a list of the stations that each subway line goes through, your task is to figure out how many transfer stations exist throughout the subway system.
Note that "loop lines" that start and end at the same station may appear in the input, and stations that are the start and end of the loop but have no other lines going through them do not count as transfer stations. For a station to be a transfer station, it has to have multiple distinct lines going through it.
The first line of input contains a single positive integer $$$n$$$: the number of lines in the subway system.
The next $$$n$$$ test cases each consist of two lines of input.
The first line consists of a single positive integer $$$m$$$: the number of stations in the given subway line
The next line contains $$$m$$$ space-separated station names, representing the route of the given subway line. The subway line might be a loop line.
Output a single positive integer $$$s$$$: the number of transfer stations in the subway system. Then, output $$$s$$$ station names: the name of each transfer station in the subway system, in alphabetical order.
6 7 Vienna EastFallsChurch Rosslyn MetroCenter LenfantPlaza StadiumArmory NewCarrolton 7 WiehleRestonEast EastFallsChurch Rosslyn MetroCenter LenfantPlaza StadiumArmory LargoTownCenter 8 FranconiaSpringfield KingStOldTown Pentagon Rosslyn MetroCenter LenfantPlaza StadiumArmory LargoTownCenter 5 BranchAvenue LenfantPlaza GalleryPlace FortTotten Greenbelt 6 Huntington KinStOldTown Pentagon LenfantPlaza GalleryPlace FortTotten 5 ShadyGrove MetroCenter GalleryPlace FortTotten Glenmont
EastFallsChurch FortTotten GalleryPlace LargoTownCenter LenfantPlaza MetroCenter Pentagon Rosslyn StadiumArmory
3 5 EastStation NorthStation WestStation SouthStation EastStation 2 WestStation CenterStation 2 NorthStation CenterStation
CenterStation NorthStation WestStation
Can you figure out which city has the subway system described in the first test case?
| Name |
|---|


