All submissions for this problem are available.
One of the criteria for ranking the websites over the internet could be, ranking on the basis of the number of references from other websites. References from a website to itself do not count.
You are given a list of references by different websites; you need to rank these websites.
The format of the each entry in the list is, website name (consisting of only uppercase English characters and spaces), followed by a comma and a space and then zero or more space seperated integers specifying the zero-based indices of the websites it cites. The indices are in accordance with the input specified example if the input is
TWITTER, 0 1
GOOGLE, 2 3
GOOGLE, 0 2
then Twitter is assigned index 0 & 2 and Google as 1 & 3, so on...
But due to sloppy work the listing of the websites and the references are inappropriately done (Intentionally :)). It includes:
1) A Website reference pair may exist in more than one rows of the input (see example 1, the FACEBOOK INC is listed multiple times and may have different references).
2) There may exist multiple references from the given website to some other website, in that case count them only once.
3) Some sites may reference to themselves, in that case the reference will not be counted.
Rules for ranking the websites are as follow:
1) The website referred more number of times is ranked higher.
2) If two websites were referred same number of times, the website with lexicographically earlier name first will be ranked higher.
First line of consists of the number of lines to follow. Next n (1<=n<=50) line consists of the website's name and the other websites they reference, in the format:
Website name, reference1 reference2
Each listing is of at most 100 characters long.
Output the final ranking for each website. The output should be one website name per line (see Example below).
Input: 9 GOOGLE INC, FACEBOOK INC, 0 TWITTER INC, 0 1 GOOGLE INC, FACEBOOK INC, 3 TWITTER INC, 4 3 3 4 ANOTHER GOOGLE INC, ANOTHER FACEBOOK INC, 6 ANOTHER TWITTER INC, 6 7 Output: ANOTHER GOOGLE INC GOOGLE INC ANOTHER FACEBOOK INC FACEBOOK INC ANOTHER TWITTER INC TWITTER INC
Reference for each website is ANOTHER GOOGLE INC - 2, GOOGLE INC -2, ANOTHER FACEBOOK INC - 1, FACEBOOK INC - 1, ANOTHER TWITTER INC - 0, TWITTER INC - 0.
The ANOTHER ones are lexicographically ranked higher than other non-ANOTHER ones.
|Time Limit:||0.403941 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, GO, NODEJS|
Fetching successful submissions
If you are still having problems, see a sample solution here.