对于我们在团队中进行的小牌锦标赛(2vs2),我需要制定一个“计划”,以便与谁对战。
“规则”是:
目标是制定一个计划,任何球队都不会对另一支球队进行两次比赛。
我尝试使用回溯的“沉重”方式,但正如我所想,复杂性很大,我们很快就有大量的计算可能性,所以我正在寻找能够快速制定计划的算法
这是我想要输出的一个例子,它是用我的“沉重的方式”生成的:
Tournament with 16 teams and 10 rounds
Round 0
Team 0 versus Team 1
Team 2 versus Team 3
Team 4 versus Team 5
Team 6 versus Team 7
Team 8 versus Team 9
Team 10 versus Team 11
Team 12 versus Team 13
Team 14 versus Team 15
Round 1
Team 0 versus Team 2
Team 1 versus Team 3
Team 4 versus Team 6
Team 5 versus Team 7
Team 8 versus Team 10
Team 9 versus Team 11
Team 12 versus Team 14
Team 13 versus Team 15
Round 2
Team 0 versus Team 3
Team 1 versus Team 2
Team 4 versus Team 7
Team 5 versus Team 6
Team 8 versus Team 11
Team 9 versus Team 10
Team 12 versus Team 15
Team 13 versus Team 14
Round 3
Team 0 versus Team 4
Team 1 versus Team 5
Team 2 versus Team 6
Team 3 versus Team 7
Team 8 versus Team 12
Team 9 versus Team 13
Team 10 versus Team 14
Team 11 versus Team 15
Round 4
Team 0 versus Team 5
Team 1 versus Team 4
Team 2 versus Team 7
Team 3 versus Team 6
Team 8 versus Team 13
Team 9 versus Team 12
Team 10 versus Team 15
Team 11 versus Team 14
Round 5
Team 0 versus Team 6
Team 1 versus Team 7
Team 2 versus Team 4
Team 3 versus Team 5
Team 8 versus Team 14
Team 9 versus Team 15
Team 10 versus Team 12
Team 11 versus Team 13
Round 6
Team 0 versus Team 7
Team 1 versus Team 6
Team 2 versus Team 5
Team 3 versus Team 4
Team 8 versus Team 15
Team 9 versus Team 14
Team 10 versus Team 13
Team 11 versus Team 12
Round 7
Team 0 versus Team 8
Team 1 versus Team 9
Team 2 versus Team 10
Team 3 versus Team 11
Team 4 versus Team 12
Team 5 versus Team 13
Team 6 versus Team 14
Team 7 versus Team 15
Round 8
Team 0 versus Team 9
Team 1 versus Team 8
Team 2 versus Team 11
Team 3 versus Team 10
Team 4 versus Team 13
Team 5 versus Team 12
Team 6 versus Team 15
Team 7 versus Team 14
Round 9
Team 0 versus Team 10
Team 1 versus Team 11
Team 2 versus Team 8
Team 3 versus Team 9
Team 4 versus Team 14
Team 5 versus Team 15
Team 6 versus Team 12
Team 7 versus Team 13
答案 0 :(得分:3)
如果您只想要预定几轮,请随机播种参与者,然后应用循环法。最简单的方法是为团队安排符号,如下所示:
A B C D
E F G H
所以,在第一轮中,配对是A
- E
,B
- F
等。然后A
是固定的,所有其他人顺时针旋转一个地方:
A E B C
F G H D
重复。
如果轮次数小于 n - 1 ,我建议使用瑞士系统。你可以手工完成配对,但是已经有许多配对程序,有些使用启发式,有些是Edmond的“开花”最小权重完美匹配算法的变体。
答案 1 :(得分:0)
您可以调整选择排序算法以生成排列。很久以前我做过这样的事。请参阅this article中的“成对排列”部分。
Pascal中的代码,但应该很容易转换为C#。