You are not logged in. Please login at to post your questions!


RIO1 - Editorial



Author: Vishal Khopkar




Graphs, sorting


RIO Olympics 2016 is hosting a team event where n teams are segregated into k groups such that n%k=0 and each group contains n/k teams. You've been given a partial schedule of the tournament and job is to segregate the teams into k different groups. However, neither n nor k has been directly given to you. What has been given is the partial schedule of x matches. With the help of this schedule, you need to print the teams segregated into different groups in alphabetical order. Also print the two groups by printing the group which contains the alphabetically first team first. Although the schedule is partial, it contains at least one match of each team.


Read each line of the schedule and form a graph accordingly. Draw an edge between two teams if there is a match between them. For example, if the first match is BRAZIL vs ARGENTINA, there would be an edge between Brazil and Argentina in the graph. For more explanation, you can see the image in the link :


Hence, just see the number of connected components in that graph. However, you need to see that there are equal number of teams in each group. Hence, you may need to merge a few connected components to make a group.


Thanking Mr. Manas Kumar Varma for the solution


asked 02 Nov '16, 17:29

abhirajphadnis's gravatar image

accept rate: 0%

edited 29 Mar '17, 12:50

admin's gravatar image

0★admin ♦♦

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 02 Nov '16, 17:29

question was seen: 579 times

last updated: 29 Mar '17, 12:50