The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
There are N participants in a chess competition. They are given unique ids, numbered from 1 to N. Every participant will play against every other participant in a game. Thus there will be (N*(N-1))/2 games in total. Assume none of the games result in a draw.
Â
A sponsor wants to meet all the players. But he can do so only one by one and in the following manner-
Â
Â
Help him decide an order such that he is able to meet all the players.
If there are multiple such orders, output the lexicographically smallest one.
The games are such that if a defeats b, and b defeats c, then a defeats c.
He doesn't want to meet any player more than once.
Â
Â
Â
Â
For each test case, output in a single line the required order.
Â
Â
Â
1T
1N
Â
Input
3
3
011
000
010
2
0
1
4
0010
1010
0000
1110
Output
1 3 2
2 1
4 2 1 3
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll