运动员最佳配对问题5_4 6_5 2011-05-22 09:33:56 测试数据 1 3 10 2 3 2 3 4 3 4 5 2 2 2 3 5 3 4 5 1 回溯法 //Author:王子硕 Date:2011/5/11 //Description:运动员最佳配对问题 排列树 //似乎没有显而易见的剪枝函数与限界函数 #include <iostream> #include <fstream> #include <algorithm> #include <functional> using namespace std; class Athletes { public: Athletes(int n,int *P, int *Q); int getBest(){return best;} int* getBestx(){return bestx;} protected: private: int n;//运动员数量 int best;//最优值 int *x;//当前解向量 int *bestx;//最优解向量 int *P;//男配女优势矩阵 int *Q;//女配男优势矩阵 void Backtrace(int t); void com();//计算当前排列值 }; Athletes::Athletes(int n,int *P, int *Q){ this->n = n; this->P = P; this->Q = Q; best = 0; x = new int[n + 1]; bestx = new int[n + 1]; for (int i = 1; i <= n;