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
19 freelancere byder i gennemsnit $32 på dette job
I am an experienced programmer with over 3 years experience in Java, C#, 5 years in C, C++. I am good at math, algorithm and always provide clean code, well documented.
I have read your requirement. I have 3 years programming experiences. I already have skills like your project. If you choose me, I will not let you down. I will wait for your reply
Hi, I will provide documented code along with build/run instructions. I plan to this in C++ under Linux ? gcc compiler. Any objections? I'm looking forward to working with you!
hy i can help you with this , and i can provide you a solution in less than 24 hours if you award project to me. please contact if you are interested in my offer thanks
Hello, sir. I am very interested in your job. I already made demo for you. I want show my demo to you. Looking forward your reply. Thank you. Best regards.
Hello. I am a new freelancer. I am C++ developer and have a experience of program develop. I understand your requirement and can do it. If you award me, I will not let you down. Thank you for your attention.