TopCoder problem "TheBasketballDivTwo" used in SRM 453 (Division II Level Two)

Problem Statement


John and Brus have an interest in team sports tournaments. They are currently investigating a basketball tournament. Basketball is a team sport in which two teams of five players try to score points against one another by placing a ball through a ten foot high hoop. Basketball is one of the most popular and widely viewed sports in the world.

There are n teams in the tournament. Each pair of teams plays exactly two games against each other. In the first of these games, one of the teams is the host, and in the second, the other team is the host. Each game results in one team winning. There are no draws. After the tournament is over, the team with the highest total number of wins is crowned the winner.

The tournament is currently in progress and the current results are described in the String[] table. For each pair of distinct indices, i and j, the j-th character of the i-th element of table is the result of the game where team i hosted team j. The result is 'W' if team i won, 'L' if team i lost, and '?' if the game hasn't been played yet. Assuming that every possible outcome is possible for the games that haven't been played yet, return the minimal number of total wins the tournament winner can have at the end of the tournament.



Method signature:int find(String[] table)
(be sure your method is public)


-table will contain between 2 and 5 elements, inclusive.
-Each element of table will contain exactly n characters, where n is the number of elements in table.
-The j-th character of the i-th element of table, where i and j are different, will be 'W', 'L', or '?'.
-The i-th character of the i-th element of table will be 'X'.


{"X?", "?X"}
Returns: 1
One win for each team.
{"XW", "LX"}
Returns: 2
The tournament is over.
{"XWL", "?XW", "WLX"}
Returns: 2
The only game that hasn't been played yet is between the first and second teams. If the first team wins the game, all of the teams will finish with two wins.
{"XW?", "LX?", "??X"}
Returns: 2

Problem url:

Problem stats url:




PabloGilberto , ivan_metelsky , Chmel_Tolstiy

Problem categories: