2014
02-24

# Campus Recruit

With the new recruiting season’s coming, lots of famous corporations come on campus to recruit new employees.

There are m corporations numbered from 1 to m, each of which has certain available positions for hiring students. The total number of the available positions is P. There are n students numbered from 1 to n. It is guaranteed that P ≤ n. Each corporation has a different preference for each student, which is denoted by an positive integer; the bigger the better. Each student has a different preference for each corporation, which is denoted by an positive integer; the bigger the better. All the preference numbers are not greater than 10,000.

The task, naturally, is to find a way of assigning each student to at most one corporation. In such a way, all available positions in all corporations are filled. Meanwhile we hope the assignment is stable. We say that the assignment is stable if neither of the following situations arises.

First type of instability: There are two students s and s’, and a corporation c. The assignment is instable if

- s is assigned to c, and

- s’ is assigned to no corporation, and

- c prefers s’ to s.

Second type of instability: There are two students s and s’, and two corporations c and c’. The assignment is instable if

- s is assigned to c, and

- s’ is assigned to c’, and

- c prefers s’ to s, and

- s’ prefers c to c’.

We would like to find a stable assignment. Can you solve it?

The input contains several cases. The first line of each case contains two integers m (1 ≤ m ≤ 100) and n (1 ≤ n ≤ 1000), indicating the number of corporations and students. This is followed by one line, containing m integers, in which the ith number indicates the number of available positions of ith corporation. This is followed by m lines, each containing n integers, in which the jth element of the ith line indicates the preference of the ith corporation to the jth student. This is followed by n lines, each containing m integers, in which the jth element of the ith line indicates the preference of the ith student to the jth corporation. The input ends with m=0 and n=0.

The input contains several cases. The first line of each case contains two integers m (1 ≤ m ≤ 100) and n (1 ≤ n ≤ 1000), indicating the number of corporations and students. This is followed by one line, containing m integers, in which the ith number indicates the number of available positions of ith corporation. This is followed by m lines, each containing n integers, in which the jth element of the ith line indicates the preference of the ith corporation to the jth student. This is followed by n lines, each containing m integers, in which the jth element of the ith line indicates the preference of the ith student to the jth corporation. The input ends with m=0 and n=0.

2 3
1 1
3 2 1
2 3 1
1 2
2 1
1 2
2 3
1 1
3 2 1
2 3 1
1 2
2 1
1 2
0 0

1 2 0

1 2 0

/*
题意：这道题估计是太简单，在网上都找不到答案，貌似思路是有的
就是两个人在一个圆桌上面放硬币，不能重叠，各种，然后最后谁放不下啦就输啦
思路：大神那儿得来的，我是想不出来，见链接吧。
*/
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
double a,b;
while(scanf("%lf%lf",&a,&b)!=EOF)
{
if(a>=b) cout << "Yes, Mr. Wendy is a ****ing genius!" << endl;
else cout << "No, Mr. Pian is the real ****ing genius!" << endl;
}
return 0;
}

HOJ 2939 Coin Question

1. 叨姐，请你眼睛盯着心看，然后把你的小脑袋上下晃动，注意眼睛不要动哦！盯着心看，然后你就会发现很神奇的一幕！！！！！！！！！！！PS（你的同事都好奇的看着你说你是逗逼）叫你不选我。请叫我。。。。。。。。。。。

2. 叨姐，请你眼睛盯着心看，然后把你的小脑袋上下晃动，注意眼睛不要动哦！盯着心看，然后你就会发现很神奇的一幕！！！！！！！！！！！PS（你的同事都好奇的看着你说你是逗逼）叫你不选我。请叫我。。。。。。。。。。。

3. 叨姐，请你眼睛盯着心看，然后把你的小脑袋上下晃动，注意眼睛不要动哦！盯着心看，然后你就会发现很神奇的一幕！！！！！！！！！！！PS（你的同事都好奇的看着你说你是逗逼）叫你不选我。请叫我。。。。。。。。。。。

4. 叨姐，请你眼睛盯着心看，然后把你的小脑袋上下晃动，注意眼睛不要动哦！盯着心看，然后你就会发现很神奇的一幕！！！！！！！！！！！PS（你的同事都好奇的看着你说你是逗逼）叫你不选我。请叫我。。。。。。。。。。。

5. 叨姐，请你眼睛盯着心看，然后把你的小脑袋上下晃动，注意眼睛不要动哦！盯着心看，然后你就会发现很神奇的一幕！！！！！！！！！！！PS（你的同事都好奇的看着你说你是逗逼）叫你不选我。请叫我。。。。。。。。。。。

6. 叨姐，请你眼睛盯着心看，然后把你的小脑袋上下晃动，注意眼睛不要动哦！盯着心看，然后你就会发现很神奇的一幕！！！！！！！！！！！PS（你的同事都好奇的看着你说你是逗逼）叫你不选我。请叫我。。。。。。。。。。。

7. 问题3是不是应该为1/4 .因为截取的三段，无论是否能组成三角形， x， y-x ，1-y,都应大于0，所以 x<y,基础应该是一个大三角形。小三角是大三角的 1/4.

8. 代码是给出了，但是解析的也太不清晰了吧！如 13 abejkcfghid jkebfghicda
第一步拆分为 三部分 (bejk, cfghi, d) * C(13,3)，为什么要这样拆分，原则是什么？