算法以确保每个人都在同一组中。

huangapple go评论63阅读模式
英文:

algorithm for making sure everyone is in the same group

问题

在一组 x 人中,您必须选择至少 2 人,其中至少有 1 人保证会被选中加入您的小组,是否可以确保每个人都在同一组中?

尝试将人们排成一个圆圈,并确保每个人选择他们前面和后面的人。

英文:

a group of x people where you have to choose 2 people at least 1 person is guaranteed to be selected to be in your group, is it possible to make sure everyone is in the same group

try to sort people in a circle and make sure everyone selects the person in front of them and behind them

答案1

得分: 1

开始于一个三角形 — 3个人,每个人都选择其他两个人。他们肯定会最终进入同一组,因为至少有两人会被分在同一组,而第三人选择了他们两个。

现在,你可以将任意多的人添加到这个组中。每个新加入的人只需选择已经保证在组中的两个人,然后他们也将被保证进入该组。

英文:

Start with a triangle -- 3 people, each of which selects the other two. They are guaranteed to end up in the same group, because at least 2 of them will be grouped, and the 3rd person selected both of them.

Now you can add as many people to the group as you like. Each new person just has to select 2 people that are already guaranteed to be in the group. and then they will be guaranteed to be in the group as well.

huangapple
  • 本文由 发表于 2023年6月19日 17:26:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76505302.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定