作者ric2k1 (Ric)
看板EE_DSnP
标题[情报] HW6-3 提示...
时间Mon Dec 3 02:46:25 2007
刚刚写了一下第三题...
这题有点复杂, 主要是允许了志愿没有选满且要顾虑公平性...
因为觉得没有必要, 我将题目的 bool setChoices() 改成 void setChoices().
以下是我的 algorithm... 不想被雷到的请按左键离开
=============
// Algorithm:
// 1. Record the remaining quota for each instructor in an array
// quota[INST_TOTAL]. Initially _maxQuota for every one.
// 2. Record the first choices of instructors from everyone into an array
// first[INST_TOTAL].
// 3. If there exists any of the |first[i]| >= quota[i], randomly pick
// quota[i] students for this instructor and set quota[i] = 0.
// Else, go to 5.
// 4. For those students who fell out of choices in 3, add their next choices
// to first[INST_TOTAL]. Go to 3.
// 5. Satisfy all first[INST_TOTAL], adjust quota[i] accordingly.
// 6. If there's any quota[i] != 0, go to 2.
// 7. Find the students who hasn't got an instructor, randomly assign an
// instructor
看不懂? 啊... 你可以用你的方法, 或是我星期二说明一下好了...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.121.132.121