The United Nations hosts many events in which they have to seat representatives of various countries. Sometimes, countries are not on good terms and it would be bad form to seat the representatives of these countries next to each other. For example currently Pakistan is not too happy with the United States and would prefer not to sit next them at the dinner table. You work for the United Meeting of Diplomats Service (UMDs) and need to write a program to help them seat the diplomats. You can assume the table at which they will be seated is round so that the first country will sit next to the last country. Each country will present you with a list of “undesirable” neighbors which they want to avoid and your program will output a list of countries which represents a seating chart for the event.
For example Pakistan wants to avoid India, and the United States. The United States wants to avoid China. India wants to avoid France. China wants to avoid the US. France wants to avoid India. One possible seating is : Pakistan, China, India, US, and France.
Input All input will be from the keyboard. The first line of input n will be an integer containing the number of test cases. The first line of a test case will contain an integer m indicating the number of countries to be represented. The next m ( m > 1 )lines will contain each countries list of undesirable neighbors. The list of neighbors to avoid begins with an integer k ( k > 0) followed by k + 1 country codes (each separated by a single space) . Each country code will be 3 letters. The first country code is the name of country submitting the list. The remaining k country codes represent the list of countries to be avoided.
Output For each case there will be 1 line of output containing a list of countries or the word impossible . The list of the countries start with the first country in the input list and then continue in order. If more than one list satisfies all the criteria print the one which comes first alphabetically.
2 PAK IND USA
1 USA CHI
1 IND FRA
1 CHI USA
1 FRA IND
2 PAK IND USA
1 USA CHI
2 IND CHI FRA
2 CHI USA IND
1 FRA IND
Sample Output PAK CHI IND USA FRA
10 freelancere byder i gennemsnit $19 for dette job
Hi, I am C++ expert and can surely help you here with this project. I have a lot of experience in helping students with their assignments and tutoring. Please communicate to discuss further. Thank you. Regards Anshu
Hello. My name is Sergey. I wark a system programmer. I think, you task is interested and I will not have difficulties with its implementation. Thank you)
I can have this project completed within 2 days of your acceptance of my bid. The code will be commented and I will answer any questions you have about it.
I have done similar projects in my past. This is a problem that falls under the "Ménage problems" section. You can google for that. I can have this done in a couple of days. Thank you and good luck.
Hi there, I can provide you a solution in no time for the project and if needed additional details about the implementation. Please contact me about any additional information. Best wishes, Cristina