作者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