#include <iostream>
using namespace std;
void initialize(int& m, int& n,int choiceMachine[lbk][rbk],int time[lbk][rbk],int inOrder[lbk][rbk]) {
cin >> m >> n;
for (int i = 0; i < n * m; i++) {
cin >> inOrder[lbk]i[rbk];
}
for (int i = 0; i < m*n; i=i+m) {
for(int j=0;j<m;j++)
cin>>choiceMachine[lbk]i+j[rbk];
}
for (int i = 0; i < m*n; i=i+m) {
for (int j = 0; j < m; j++)
cin >> time[lbk]i + j[rbk];
}
return;
}
bool finishWork(int m,int n,int order[lbk][rbk],int machine_status[lbk][rbk],int user[lbk][rbk]) {
//返回为true则所有工作已经完成
bool f1 = true;
bool f2 = true;
bool f3 = true;
for (int i = 0; i < 10000;i++) {
if (order[lbk]i[rbk] != 0) {
f1 = false;
break;
}
}
for (int i = 0; i < 10000; i++) {
if (machine_status[lbk]i[rbk] != 0) {
f2 = false;
}
}
for (int i = 0; i < 10000; i++) {
if (user[lbk]i[rbk] != 0) {
f3 = false;
}
}
if (f1 && f2 && f3)
return true;
else
return false;
}
void run(int& m, int& n,int choiceMachine[lbk][rbk], int time[lbk][rbk], int inOrder[lbk][rbk]) {
int machine[lbk]10000[rbk] = { 0 };//记录对应机器加工的工件
int use[lbk]10000[rbk] = {0};//记录正在加工的工件,1为正在加工0为加工结束
int machine_status[lbk]10000[rbk] = { 0 }; //记录机器状态0即空闲1即占用
int totaltime = 0;
int workTime[lbk]10000[rbk] = { 0 };
for (int i = 0; i < m * n; i++) { //遍历inOrder顺序
if (inOrder[lbk]i[rbk] != 0 && use[lbk]inOrder[lbk]i[rbk]-1[rbk]==0) { //该步未完成且该工件未占用
for (int j = (inOrder[lbk]i[rbk] - 1) * m; j < inOrder[lbk]i[rbk] * m; j++) {
if (choiceMachine[lbk]j[rbk] != 0) {
if (machine_status[lbk]choiceMachine[lbk]j[rbk]-1[rbk] == 0) {//该机器空闲
//cout << "工件号:" << inOrder[lbk]i[rbk] << ",工序:" << j - (inOrder[lbk]i[rbk] - 1) * m + 1 << ",工作机器:" << choiceMachine[lbk]j[rbk] <<",用时:"<<time[lbk]j[rbk] <<",当前时间:"<<totaltime << endl;
using namespace std;
void initialize(int& m, int& n,int choiceMachine[lbk][rbk],int time[lbk][rbk],int inOrder[lbk][rbk]) {
cin >> m >> n;
for (int i = 0; i < n * m; i++) {
cin >> inOrder[lbk]i[rbk];
}
for (int i = 0; i < m*n; i=i+m) {
for(int j=0;j<m;j++)
cin>>choiceMachine[lbk]i+j[rbk];
}
for (int i = 0; i < m*n; i=i+m) {
for (int j = 0; j < m; j++)
cin >> time[lbk]i + j[rbk];
}
return;
}
bool finishWork(int m,int n,int order[lbk][rbk],int machine_status[lbk][rbk],int user[lbk][rbk]) {
//返回为true则所有工作已经完成
bool f1 = true;
bool f2 = true;
bool f3 = true;
for (int i = 0; i < 10000;i++) {
if (order[lbk]i[rbk] != 0) {
f1 = false;
break;
}
}
for (int i = 0; i < 10000; i++) {
if (machine_status[lbk]i[rbk] != 0) {
f2 = false;
}
}
for (int i = 0; i < 10000; i++) {
if (user[lbk]i[rbk] != 0) {
f3 = false;
}
}
if (f1 && f2 && f3)
return true;
else
return false;
}
void run(int& m, int& n,int choiceMachine[lbk][rbk], int time[lbk][rbk], int inOrder[lbk][rbk]) {
int machine[lbk]10000[rbk] = { 0 };//记录对应机器加工的工件
int use[lbk]10000[rbk] = {0};//记录正在加工的工件,1为正在加工0为加工结束
int machine_status[lbk]10000[rbk] = { 0 }; //记录机器状态0即空闲1即占用
int totaltime = 0;
int workTime[lbk]10000[rbk] = { 0 };
for (int i = 0; i < m * n; i++) { //遍历inOrder顺序
if (inOrder[lbk]i[rbk] != 0 && use[lbk]inOrder[lbk]i[rbk]-1[rbk]==0) { //该步未完成且该工件未占用
for (int j = (inOrder[lbk]i[rbk] - 1) * m; j < inOrder[lbk]i[rbk] * m; j++) {
if (choiceMachine[lbk]j[rbk] != 0) {
if (machine_status[lbk]choiceMachine[lbk]j[rbk]-1[rbk] == 0) {//该机器空闲
//cout << "工件号:" << inOrder[lbk]i[rbk] << ",工序:" << j - (inOrder[lbk]i[rbk] - 1) * m + 1 << ",工作机器:" << choiceMachine[lbk]j[rbk] <<",用时:"<<time[lbk]j[rbk] <<",当前时间:"<<totaltime << endl;