You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
263 lines
10 KiB
263 lines
10 KiB
#include <iostream>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include <set>
|
|
|
|
std::string slurp(std::ifstream& in) {
|
|
std::ostringstream sstr;
|
|
sstr << in.rdbuf();
|
|
return sstr.str();
|
|
}
|
|
|
|
struct ScoreData{
|
|
int difficulty=0;
|
|
std::string song;
|
|
int totalEX=0;
|
|
int ex1=0,ex2=0,ex3=0;
|
|
std::string str()const{
|
|
return "["+std::to_string(difficulty)+"] "+song+": "+std::to_string(totalEX)+" total, "+" EX1: "+std::to_string(ex1)+" EX2: "+std::to_string(ex2)+" EX3: "+std::to_string(ex3);
|
|
}
|
|
friend std::ostream&operator<<(std::ostream&os,const ScoreData&data){
|
|
os<<data.str();
|
|
return os;
|
|
}
|
|
};
|
|
|
|
std::string GetNext(int&marker,std::string str){
|
|
int originalMarker=marker;
|
|
marker=str.find_first_of(',',originalMarker)+1;
|
|
return str.substr(originalMarker,marker-1);
|
|
};
|
|
|
|
struct TestCase{
|
|
int p1Amt,p2Amt,p3Amt;
|
|
};
|
|
|
|
struct SongCombinations{
|
|
std::vector<std::pair<int,int>>p1; //Index to song followed by EX of song.
|
|
std::vector<std::pair<int,int>>p2;
|
|
std::vector<std::pair<int,int>>p3;
|
|
std::set<int>p1Picked;
|
|
std::set<int>p2Picked;
|
|
std::set<int>p3Picked;
|
|
int totalEX=0;
|
|
int remainingA,remainingB,remainingC;
|
|
};
|
|
|
|
int main(){
|
|
std::vector<ScoreData>dataA,dataB;
|
|
std::vector<std::pair<int,int>>player1Score,player2Score,player3Score;
|
|
std::ifstream file("team2.csv");
|
|
std::string line;
|
|
//First two lines are garbage data.
|
|
std::getline(file,line);
|
|
std::getline(file,line);
|
|
for(int i=0;i<12;i++){
|
|
std::getline(file,line);
|
|
int marker=0;
|
|
ScoreData dat{
|
|
stoi(GetNext(marker,line)),
|
|
GetNext(marker,line),
|
|
stoi(GetNext(marker,line)),
|
|
stoi(GetNext(marker,line)),
|
|
stoi(GetNext(marker,line)),
|
|
stoi(GetNext(marker,line))};
|
|
player1Score.emplace_back(std::pair<int,int>{dat.ex1,0});
|
|
player2Score.emplace_back(std::pair<int,int>{dat.ex2,0});
|
|
player3Score.emplace_back(std::pair<int,int>{dat.ex3,0});
|
|
dataA.emplace_back(dat);
|
|
}
|
|
//Two more lines of garbage data.
|
|
std::getline(file,line);
|
|
std::getline(file,line);
|
|
for(int i=0;i<12;i++){
|
|
std::getline(file,line);
|
|
int marker=0;
|
|
ScoreData dat{
|
|
stoi(GetNext(marker,line)),
|
|
GetNext(marker,line),
|
|
stoi(GetNext(marker,line)),
|
|
stoi(GetNext(marker,line)),
|
|
stoi(GetNext(marker,line)),
|
|
stoi(GetNext(marker,line))};
|
|
player1Score[i].second=dat.ex1;
|
|
player2Score[i].second=dat.ex2;
|
|
player3Score[i].second=dat.ex3;
|
|
dataB.emplace_back(dat);
|
|
}
|
|
std::cout<<"File Contents:"<<std::endl<<std::endl;
|
|
for(auto&list:{dataA,dataB}){
|
|
for(auto&dat:list){
|
|
std::cout<<dat<<std::endl;
|
|
}
|
|
}
|
|
std::cout<<"==================="<<std::endl;
|
|
|
|
std::vector<TestCase>cases;
|
|
for(int i=0;i<5;i++){
|
|
for(int j=0;j<5;j++){
|
|
for(int k=0;k<5;k++){
|
|
if(i+j+k==6){
|
|
cases.emplace_back(TestCase{i,j,k});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
auto ChooseSong = [](SongCombinations&combinations,std::vector<ScoreData>&dat,int index){
|
|
if(combinations.remainingA>0&&combinations.p1Picked.count(index)==0){
|
|
combinations.remainingA--;
|
|
combinations.totalEX+=dat[index].ex1;
|
|
combinations.p1.emplace_back(std::pair<int,int>{index,dat[index].ex1});
|
|
combinations.p1Picked.insert(index);
|
|
}else
|
|
if(combinations.remainingB>0&&combinations.p2Picked.count(index)==0){
|
|
combinations.remainingB--;
|
|
combinations.totalEX+=dat[index].ex2;
|
|
combinations.p2.emplace_back(std::pair<int,int>{index,dat[index].ex2});
|
|
combinations.p2Picked.insert(index);
|
|
}else
|
|
if(combinations.remainingC>0&&combinations.p3Picked.count(index)==0){
|
|
combinations.remainingC--;
|
|
combinations.totalEX+=dat[index].ex3;
|
|
combinations.p3.emplace_back(std::pair<int,int>{index,dat[index].ex3});
|
|
combinations.p3Picked.insert(index);
|
|
}
|
|
};
|
|
|
|
std::vector<SongCombinations> bestComboA,bestComboB;
|
|
int caseInd=0;
|
|
for(TestCase&_case:cases){
|
|
bestComboA.push_back({});
|
|
bestComboA[caseInd].remainingA=_case.p1Amt;
|
|
bestComboA[caseInd].remainingB=_case.p2Amt;
|
|
bestComboA[caseInd].remainingC=_case.p3Amt;
|
|
for(int i=0;i<12;i++){
|
|
SongCombinations c1=bestComboA[caseInd];
|
|
ChooseSong(c1,dataA,i);
|
|
for(int j=0;j<12;j++){
|
|
SongCombinations c2=c1;
|
|
ChooseSong(c2,dataA,j);
|
|
for(int k=0;k<12;k++){
|
|
SongCombinations c3=c2;
|
|
ChooseSong(c3,dataA,k);
|
|
for(int l=0;l<12;l++){
|
|
SongCombinations c4=c3;
|
|
ChooseSong(c4,dataA,l);
|
|
for(int m=0;m<12;m++){
|
|
SongCombinations c5=c4;
|
|
ChooseSong(c5,dataA,m);
|
|
for(int n=0;n<12;n++){
|
|
SongCombinations c6=c5;
|
|
ChooseSong(c6,dataA,n);
|
|
if(bestComboA[caseInd].totalEX<c6.totalEX){
|
|
bestComboA[caseInd]=c6;
|
|
bestComboA[caseInd].totalEX=c6.totalEX;
|
|
std::cout<<"New Best Song Combinations found for Case ("<<_case.p1Amt<<","<<_case.p2Amt<<","<<_case.p3Amt<<") - Total EX: "<<bestComboA[caseInd].totalEX<<":"<<std::endl;
|
|
std::cout<<"\t";
|
|
for(std::pair<int,int>&p1:bestComboA[caseInd].p1){
|
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p2:bestComboA[caseInd].p2){
|
|
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p3:bestComboA[caseInd].p3){
|
|
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
|
}
|
|
std::cout<<std::endl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
caseInd++;
|
|
}
|
|
|
|
caseInd=0;
|
|
for(TestCase&_case:cases){
|
|
bestComboB.push_back({});
|
|
bestComboB[caseInd].remainingA=_case.p1Amt;
|
|
bestComboB[caseInd].remainingB=_case.p2Amt;
|
|
bestComboB[caseInd].remainingC=_case.p3Amt;
|
|
for(int i=0;i<12;i++){
|
|
SongCombinations c1=bestComboB[caseInd];
|
|
ChooseSong(c1,dataB,i);
|
|
for(int j=0;j<12;j++){
|
|
SongCombinations c2=c1;
|
|
ChooseSong(c2,dataB,j);
|
|
for(int k=0;k<12;k++){
|
|
SongCombinations c3=c2;
|
|
ChooseSong(c3,dataB,k);
|
|
for(int l=0;l<12;l++){
|
|
SongCombinations c4=c3;
|
|
ChooseSong(c4,dataB,l);
|
|
for(int m=0;m<12;m++){
|
|
SongCombinations c5=c4;
|
|
ChooseSong(c5,dataB,m);
|
|
for(int n=0;n<12;n++){
|
|
SongCombinations c6=c5;
|
|
ChooseSong(c6,dataB,n);
|
|
if(bestComboB[caseInd].totalEX<c6.totalEX){
|
|
bestComboB[caseInd]=c6;
|
|
bestComboB[caseInd].totalEX=c6.totalEX;
|
|
std::cout<<"New Best Song Combinations found for Case ("<<_case.p1Amt<<","<<_case.p2Amt<<","<<_case.p3Amt<<") - Total EX: "<<bestComboB[caseInd].totalEX<<":"<<std::endl;
|
|
std::cout<<"\t";
|
|
for(std::pair<int,int>&p1:bestComboB[caseInd].p1){
|
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p2:bestComboB[caseInd].p2){
|
|
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p3:bestComboB[caseInd].p3){
|
|
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
|
}
|
|
std::cout<<std::endl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
caseInd++;
|
|
}
|
|
|
|
int highestEX=0;
|
|
SongCombinations picked1,picked2;
|
|
for(SongCombinations&A:bestComboA){
|
|
for(SongCombinations&B:bestComboB){
|
|
if(A.totalEX+B.totalEX>highestEX&&A.p1Picked.size()+B.p1Picked.size()==4&&A.p2Picked.size()+B.p2Picked.size()==4&&A.p3Picked.size()+B.p3Picked.size()==4){
|
|
highestEX=A.totalEX+B.totalEX;
|
|
picked1=A;
|
|
picked2=B;
|
|
std::cout<<"New Best Song Combinations found for Final Picks - Total EX: "<<highestEX<<":"<<std::endl;
|
|
std::cout<<"\t Set A: ";
|
|
for(std::pair<int,int>&p1:picked1.p1){
|
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p2:picked1.p2){
|
|
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p3:picked1.p3){
|
|
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
|
}
|
|
std::cout<<std::endl;
|
|
std::cout<<"\t Set B: ";
|
|
for(std::pair<int,int>&p1:picked2.p1){
|
|
std::cout<<"P1["<<p1.first<<"]:"<<p1.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p2:picked2.p2){
|
|
std::cout<<"P2["<<p2.first<<"]:"<<p2.second<<" ";
|
|
}
|
|
for(std::pair<int,int>&p3:picked2.p3){
|
|
std::cout<<"P3["<<p3.first<<"]:"<<p3.second<<" ";
|
|
}
|
|
std::cout<<std::endl;
|
|
}
|
|
}
|
|
}
|
|
} |