Haha, today is a panic Sunday, tomorrow is Monday ~
Don't forget to study on weekends. Now, let's review discrete mathematics ~
By the way, I have a thorough understanding of the girl's skills. It's not a dream for the girl friend of programmers!
The discrete mathematics class (csci2110) has an interesting question.
Suppose there are five boys and five girls, each of whom has a certain preference order for the five opposite sexes in their own minds. For example:
The above sorting table is interpreted as follows: Boy 1 is the most popular girl C, B is the second favorite girl B, and E is the second favorite girl ....
And so on ....
After all five male and five female are successfully stripped (assuming they are all resolved within the circle), the definition of an unstablematching is: if there is a pair of men and women who are not a couple, the following conditions are met:
For this male, the female is in front of his current girlfriend in his preference list, and for this female, the male is also in front of his current boyfriend in his preference list, then this will inevitably lead to a kind of opement between men and women ....
This scenario is unstablematching. Otherwise, if there is no such pair of male with an elopement tendency, It is stablematching.
The question is: in any case, no matter how the preference list changes, as long as the number of men and women is the same, there is always a stablematching .? (Of course, it's impossible to stir up the foundation ...)
In the preceding example, A stablematching is as follows:
Because every girl's favorite boy is different, as long as the girl chooses to be with her favorite boy, they will not have the idea of moving away with other boys. Although the boys will be a little hard-pressed! It is still a stablematching .....
If there are n male and n female, each person has a preference list in his or her mind. Does stablematching always exist?
In 1962, Gale and Shapley proved that stablematching exists.
First, they gave an algorithm:
Morning on the first day: All boys confess to their favorite girls.
At noon on the first day: after each girl was confessed n times (maybe 0 times), she refused the n-1 who were not quite interested and held the most desirable one... That is, do not accept or reject the request.
On the first night, the rejected male crossed out the rejected male from his preference list...
The next morning: All boys who have not been held will confess to their favorite girl (ignoring what has been crossed out.
At noon the next day: the girls chose the most desirable one among the boys who told her their confession and those who had already held it, and refused to drop others.
The next night: The rejected boys crossed out the rejected ones in their preference list ....
On the third day, repeat the same process...
The fourth day ....
.......
Such a process is limited and will not keep repeating. (Claim1)
After this process, every girl will hold a boy. (Claim2) after that day, no boys can continue to confess, then the girls finally say yes to the boys!
According to this process, there will not be a male-opement tendency (claim3) in the end)
Stablematching is completed.
For more information about claim1, claim2, and claim3, see
The following are our key issues:
In this kind of boys' active algorithms, are boys or girls dominant?
On the surface, boys are a little hard-pressed: they are either rejected, or they are held and don't know if they will be rejected the next day. Girls have full options and enjoy the superiority of the stars and the moon, and in the worst case, there will still be a companion in the end and we will not be alone ......
But in fact, boys are dominant!
For boys,
When his girlfriend is set to the first place in his preference list, how can he catch up with the girls before I:
Because even if the girl reaches (that is, the girl is confused for a moment ),
Then the girl (marked as Y) will certainly have another male X compared to his favorite object (since it is a moment of confusion, it indicates that a more desirable boy has already confessed to her in the current situation ),
Since male x confessed to the girl at the time, it indicates that all the girls before y refused him, and if y refused him, the girl he finally joined must be behind y.
Therefore, X and Y are destined to run away!
So, none of the girls that boys can catch up with should hit or cannot be forced... That is, the girl he finally caught up with is his best choice...
For girls:
When her boyfriend was set to the first place in her preference list, all the boys before I were held by other girls before they had the chance to confess to her, that is to say, how bitter it is that she never can wait for the best...
In fact, it can also prove that this boyfriend is the worst choice she can get in all stablematching.
If she chooses I + 1, that is, she rejects I, then I can only be the same as her girl (in the eyes of I.
I + 1 is not as good as I, so she still wants to run away with I.
That is: If she chooses a boy (in her eyes) who is worse, the final pairing will be unstablematching, so there is no way to get worse! This is already the worst!
To sum up, we are surprised to find that the girl that boys catch is his best choice.
Girls accept boys, which is her worst choice.
If the opposite is true, that is, if a girl actively pursues a boy, the opposite is true.
This fact tells us how important it is to actively confess!
But ....
If shy girls do not want to voluntarily confess, they still have the opportunity to avoid this worst result. At this time, it is very important to lie a little bit .....
Suppose a simple situation, 4v4 is better.
Male 1: Bada female: 1234
MALE 2: abcd B female: 2143 (red indicates on the first day)
3 male: bcad c female: 3241
4 male: adbd D female: 4231
According to the gale Shapley algorithm,
On the first day, male 1 and male 3 are white to female B, while male 2 and male 4 are white to female.
A girl prefers 2 to 4, but she lied to 2 ("No, I don't love you ...") She refused 2
B prefers 1 to 3, but she lied to 1.
So the next morning, the rejected male 1 showed White to female A, while male 2 showed White to female B ......
The final result is:
1-A
2-B
3-C
4-D
The girls finally got the best choice.
The above facts teach us that when a girl rejects you, she may not really dislike you (at least at the time), so... There is a theoretical basis for all stalking. It cannot be equivalent to playing hooligans ....
Finally, if a boy lie (that is, he does not confess Based on the preference list and cannot deny the existence of such a young man 2b), can he finally make a more desirable girlfriend? The answer is no. Lying will only make boys more reliable in their minds. The reason is not difficult to analyze. You can try it on your own. The conclusion is: for the active party, sincerity and frankness are essential to guarantee the optimal choice...
From: Renren Shi kaixia
Scan the following QR code and follow the "Open Source China" code!
(Scan, follow the oschina number, and provide you with a selection of information early every day, as well as an oschina entertainment bullet)
Oschina entertainment bullet-Tips for Discrete Mathematics, have you learned?