Orchestration Algorithm for single-cycle group confrontation

Source: Internet
Author: User
Tags rounds

Problem description: There are two Teams A and B, each with n players. Now we want to hold a single-cycle round-robin competition, that is, we will hold n rounds of competitions, so that each team member of Team A must play with all the players of Team B.

It is required to make an orchestration table against each other:

1. Each contestant has a fight with all the contestants of the other party.

2. the absolute value of the difference in the number of successive hands of each contestant is not greater than 1 at the end of the 3rd round and later rounds.

3. In each round, the number of first-hand players in each team differs from that of the second-hand players by 1 (that is, each team should be half-first-hand and half-latter ).

Taking a 7-person group as an example, five members of Team A are set to 1, 2, 3, 4, 5, 6, and 7. The 7 members of Team B are 8, 9, 10, 11, 12, 13, and 14.

The orchestration process is as follows:

First-round orchestration Process

1. In the first round of matching, all the members of Team A are written on the top, and all the members of Team B are paired one by one. As shown below

Team A: 1 2 3 4 5 6 7

Team B: 8 9 10 11 12 13 14

The pairing table is:

1-8

2-9

3-10

4-11

5-12

6-13

7-14

2. Confirm by hand:

This round of A is the main team, and B is the main team.

A single number of first-in-first-out orders.

Therefore, the final orchestration table in the first round is

1st servers: (1)-8

2nd servers: 2-(9)

3rd servers: (3)-10

4th servers: 4-(11)

5th servers: (5)-12

6th servers: 6-(13)

7th servers: (7)-14

The contestants in parentheses hold hands first, the same below.

Now the first round of orchestration is complete.

The subsequent orchestration steps are as follows (taking the 2nd round as an example ):

1. Determine the first-hand team in this round, which is called the main team in this round. Another team is called (this round. The rule is as follows: For a singular round, a is the main team. In double round, B is the guest.

Therefore, 2nd round B is the main team and a is the guest team. The first master team is the first, and then the guest team is the first.

2. Select the first contestant from the main team in the following order. When there is only one candidate in one step, the selection is over:

(1) Find the contestants who have the least hands in the main team.

For example, the number of first hands of Team B on the 8, 10, 12, and 14 is 0. Currently, 8, 10, 12, and 14 are candidates.

(2) when the number of first hands of multiple contestants is the same, filter the ones after the last round.

For example, after the rotation is executed on the 8, 10, 12, and 14. The candidate list is still}

(3) If you are unable to distinguish contestants based on their respective situations, continue to select those who have not yet played the first game.

For example, the first server was deployed on the 8 th and was eliminated. The current list of candidates is {10, 12, 14}

(4) When multiple contestants have not played the first game, the one with the smallest number will be selected.

Therefore, Team B finally takes the lead on the first server on the 10th.

In the future, the first contestant in the main team will be X. Its opponent is Y.

3. Steps for selecting the first contestant, y:

(1) Find out all contestants who have not yet played X.

For example, if Team A has not reached the 10th, there are, and candidates. The list of candidates for the primary election is }.

(2) If there are multiple candidates, find the least number of candidates from the list of candidates for X.

For example, if the number of hind hands of 1, 5, and 7 is 0, 4, and 6, the number of hind hands is 1. 1, 5, and 7 enter the next round of selection.

(3) When multiple contestants have the same number of backers, they will be screened out.

1, 5, 7 are on the shift first. The candidate list is still {, 7}

(4) When multiple contestants take the lead, they will continue to filter out those who have not yet taken the lead.

1. I took the first server in the first round and was eliminated. Two candidates are left: {5, 7 }.

(5) When multiple contestants have not played the first game, select the one with the smallest number.

In the end, the first contestant in the second round is 5.

Therefore, the pairing result of the first server in the second round is the first-hand-to-five server on the 10 th.

4. matching methods for other servers

Start from the first server and write the other members of the two teams in ascending order of numbers under the first server. When writing to the last member of the team, the next member is the member of the team with the smallest number,

In the future, the numbers selected for each server will continue to increase.

Therefore, the pairing result for the 2nd round is:

10-5

11-6

12-7

13-1

14-2

8-3

9-4

5. How to determine the sequence: All contestants after the upper and lower rounds of the main team must be in the first place, and the latter must be in the first place. In the main team, the contestants who carry the first round will be the first, and then their opponents will be the first. Therefore, the final target table in the second round is

(10)-5

11-(6)

(12)-7

13-(1)

(14)-2

(8)-3

9-(4)

Now the second round of orchestration is complete. In the future, the main steps and results of the subsequent rounds can be written to facilitate readers.

Round 3: A is the main team, the first contestant is 2, B is the guest team, and the first contestant is 12.

(2)-12

(3)-13

4-(14)

(5)-8

6-(9)

(7)-10

1-(11)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.