


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、二部圖匹配算法(求最大匹配數(shù))Machine ScheduleProblem DescriptionAs we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. Scheduling problems differ widely in the nature of the constraints that must be satisfied and the type of schedule desire
2、d. Here we consider a 2-machine scheduling problem.There are two machines A and B. Machine A has n kinds of working modes, which is called mode_0, mode_1, , mode_n-1, likewise machine B has m kinds of working modes, mode_0, mode_1, , mode_m-1. At the beginning they are both work at mode_0.For k jobs
3、 given, each of them can be processed in either one of the two machines in particular mode. For example, job 0 can either be processed in machine A at mode_3 or in machine B at mode_4, job 1 can either be processed in machine A at mode_2 or in machine B at mode_4, and so on. Thus, for job i, the con
4、straint can be represent as a triple (i, x, y), which means it can be processed either in machine A at mode_x, or in machine B at mode_y.Obviously, to accomplish all the jobs, we need to change the machine's working mode from time to time, but unfortunately, the machine's working mode can on
5、ly be changed by restarting it manually. By changing the sequence of the jobs and assigning each job to a suitable machine, please write a program to minimize the times of restarting machines. InputThe input file for this program consists of several configurations. The first line of one configuratio
6、n contains three positive integers: n, m (n, m < 100) and k (k < 1000). The following k lines give the constrains of the k jobs, each line is a triple: i, x, y.The input will be terminated by a line containing a single zero.OutputThe output should be one integer per line, which means the minim
7、al times of restarting machine.Sample Input5 5 100 1 11 1 22 1 33 1 44 2 15 2 26 2 37 2 48 3 39 4 30Sample Output3#include <stdio.h>#define N 100#define M 100int useifM; /記錄當(dāng)前y中節(jié)點是否使用int linkM; /記錄當(dāng)前與y節(jié)點相連的x的節(jié)點int mapNM;/記錄連接x和y的邊,如果i和j之間有邊則為1,否則為0int n, m; /二分圖中x和y中點的數(shù)目int k; /預(yù)設(shè)的邊數(shù) int match
8、(int x) /從X向Y中找匹配點,形成匹配邊X<->Y int i; for(i=1;i<=m;i+) if(useifi=0 && mapxi) useifi=1; if(linki=-1 | match(linki) linki=x; /printf("map a%d to b%dn", x, i); return 1; return 0;int MaxMatch()/為每一個X點找Y匹配點,形成最大匹配 int i, num=0; memset(link,-1,sizeof(link); for (i=1; i<=n; i+) memset(useif,0,sizeof(useif); if(match(i) num+; return num;int Init() int i, s, x, y; scanf("%d", &n); if (n=0) return 0; scanf("%d%d",&m,&k); memset(map,0,sizeof(map); for (i=1; i<=k; i+) scanf("%d%d%d",
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 自然語言及語音處理項目式教程 實訓(xùn)指導(dǎo) 實訓(xùn)1 配置NLP環(huán)境
- 分析師預(yù)期選股策略月報:分析師預(yù)期修正選股策略今年相對中證全指超額3.06
- 2025以色列與伊朗沖突全面解析課件
- 氫能源未來2025年加氫站建設(shè)成本效益分析與布局指南報告
- 2025年家具制造業(yè)個性化定制生產(chǎn)模式市場風(fēng)險預(yù)警報告
- 2025年煤炭清潔燃燒技術(shù)產(chǎn)業(yè)鏈上下游協(xié)同發(fā)展報告
- 工業(yè)互聯(lián)網(wǎng)平臺安全多方計算在智能倉儲物流中的應(yīng)用報告
- 教育大數(shù)據(jù)分析2025年:教育資源配置優(yōu)化與教育公平研究報告
- 工業(yè)互聯(lián)網(wǎng)平臺網(wǎng)絡(luò)安全態(tài)勢感知技術(shù)在電力行業(yè)的應(yīng)用與優(yōu)化報告
- 工業(yè)互聯(lián)網(wǎng)平臺安全多方計算技術(shù):2025年網(wǎng)絡(luò)安全風(fēng)險預(yù)警與應(yīng)對策略研究報告
- 公路工程基本建設(shè)項目概算、預(yù)算編制辦法
- 最詳細(xì)的整車開發(fā)流程
- 部編版七年級歷史(下)材料論述題專項訓(xùn)練
- 年產(chǎn)1000噸乳酸的生產(chǎn)工藝設(shè)計
- 博克服裝CAD制版說明操作手冊(共95頁)
- 光電效應(yīng)測普朗克常數(shù)-實驗報告
- (完整word版)數(shù)據(jù)模型與決策課程案例分析
- 自制桁架移動式操作平臺施工方案
- 物業(yè)服務(wù)參與校園文化建設(shè)及舉辦大型活動配合措施
- 太陽能LED路燈項目實施方案
- 調(diào)崗調(diào)薪實操指引PPT課件
評論
0/150
提交評論