Loading problem...
A competitive gaming platform stores round-robin stage data in two tables.
Table players:
Table matches:
Business rules:
Task:
Output requirements:
Supported submission environments:
players:
| player_id | group_id |
|-----------|----------|
| 15 | 1 |
| 25 | 1 |
| 30 | 1 |
| 45 | 1 |
| 10 | 2 |
| 35 | 2 |
| 50 | 2 |
| 20 | 3 |
| 40 | 3 |
matches:
| match_id | first_player | second_player | first_score | second_score |
|----------|--------------|---------------|-------------|--------------|
| 1 | 15 | 45 | 3 | 0 |
| 2 | 30 | 25 | 1 | 2 |
| 3 | 30 | 15 | 2 | 0 |
| 4 | 40 | 20 | 5 | 2 |
| 5 | 35 | 50 | 1 | 1 |[
{"group_id":1,"player_id":15},
{"group_id":2,"player_id":35},
{"group_id":3,"player_id":40}
]Group 1 totals are 15->3, 25->2, 30->3, 45->0, so tie at 3 is broken by smaller player_id (15). Group 2 winner is 35 with 1 point (tie with 50 broken by id). Group 3 winner is 40 with 5 points.
players:
| player_id | group_id |
|-----------|----------|
| 101 | 7 |
| 109 | 7 |
| 130 | 7 |
matches:
| match_id | first_player | second_player | first_score | second_score |
|----------|--------------|---------------|-------------|--------------|
| 1 | 101 | 130 | 4 | 0 |
| 2 | 109 | 130 | 4 | 0 |[
{"group_id":7,"player_id":101}
]Players 101 and 109 both finish with 4 points, so the lower player_id (101) is selected.
players:
| player_id | group_id |
|-----------|----------|
| 1 | 10 |
| 3 | 10 |
| 2 | 11 |
| 4 | 11 |
matches:
| match_id | first_player | second_player | first_score | second_score |
|----------|--------------|---------------|-------------|--------------|
| 1 | 2 | 4 | 1 | 1 |[
{"group_id":10,"player_id":1},
{"group_id":11,"player_id":2}
]Group 10 has no matches, so all players are at 0 and the smallest id (1) wins. Group 11 players tie at 1 point, so smallest id (2) wins.
Constraints