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.
332 lines
20 KiB
332 lines
20 KiB
1 year ago
|
#include <iostream>
|
||
1 year ago
|
#include <fstream>
|
||
|
#include <sstream>
|
||
|
#include <vector>
|
||
1 year ago
|
#include <algorithm>
|
||
1 year ago
|
|
||
|
std::string slurp(std::ifstream& in) {
|
||
|
std::ostringstream sstr;
|
||
|
sstr << in.rdbuf();
|
||
|
return sstr.str();
|
||
|
}
|
||
|
|
||
|
struct ScoreData{
|
||
1 year ago
|
int difficulty=0;
|
||
1 year ago
|
std::string song;
|
||
1 year ago
|
int totalEX=0;
|
||
|
int ex1=0,ex2=0,ex3=0;
|
||
1 year ago
|
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;
|
||
|
}
|
||
|
};
|
||
|
|
||
1 year ago
|
struct Selection{
|
||
|
std::vector<std::pair<int,int>>selectedScore;
|
||
|
int totalEX=0;
|
||
|
};
|
||
|
|
||
1 year ago
|
std::string GetNext(int&marker,std::string str){
|
||
|
int originalMarker=marker;
|
||
|
marker=str.find_first_of(',',originalMarker)+1;
|
||
|
return str.substr(originalMarker,marker-1);
|
||
|
};
|
||
1 year ago
|
|
||
|
int main(){
|
||
1 year ago
|
std::vector<ScoreData>dataA,dataB;
|
||
|
std::ifstream file("team.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;
|
||
|
dataA.emplace_back(ScoreData{
|
||
|
stoi(GetNext(marker,line)),
|
||
|
GetNext(marker,line),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line))}
|
||
|
);
|
||
|
}
|
||
|
//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;
|
||
|
dataB.emplace_back(ScoreData{
|
||
|
stoi(GetNext(marker,line)),
|
||
|
GetNext(marker,line),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line)),
|
||
|
stoi(GetNext(marker,line))}
|
||
|
);
|
||
|
}
|
||
1 year ago
|
std::cout<<"File Contents:"<<std::endl<<std::endl;
|
||
1 year ago
|
for(auto&list:{dataA,dataB}){
|
||
|
for(auto&dat:list){
|
||
|
std::cout<<dat<<std::endl;
|
||
|
}
|
||
|
}
|
||
1 year ago
|
std::cout<<"==================="<<std::endl;
|
||
|
std::vector<Selection>bestSelections;
|
||
1 year ago
|
Selection selection;
|
||
|
ScoreData*dataRef;
|
||
|
std::vector<int>sortedChoices={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
|
||
|
std::sort(sortedChoices.begin(),sortedChoices.end(),[&](int&val1,int&val2){
|
||
|
int ex1;
|
||
|
int ex2;
|
||
|
if(val1<12){
|
||
|
ex1=dataA[val1].totalEX;
|
||
1 year ago
|
}else{
|
||
1 year ago
|
ex1=dataB[val1-12].totalEX;
|
||
1 year ago
|
}
|
||
1 year ago
|
if(val2<12){
|
||
|
ex2=dataA[val2].totalEX;
|
||
1 year ago
|
}else{
|
||
1 year ago
|
ex2=dataB[val2-12].totalEX;
|
||
1 year ago
|
}
|
||
1 year ago
|
return ex1>ex2;
|
||
|
});
|
||
|
|
||
|
for(int a1=0;a1<24;a1++){
|
||
|
int Aselections=6,Bselections=6;
|
||
|
selection.selectedScore.clear();
|
||
|
selection.totalEX=0;
|
||
|
std::vector<int>remainingChoices=sortedChoices;
|
||
|
int arrInd=a1;
|
||
|
if(Aselections==0&&remainingChoices[a1]<12||Bselections==0&&remainingChoices[a1]>=12)continue;
|
||
|
selection.selectedScore.push_back({0,remainingChoices[arrInd]});
|
||
|
if(remainingChoices[arrInd]<12){
|
||
|
Aselections--;
|
||
|
dataRef=&dataA[remainingChoices[arrInd]];
|
||
|
}else{
|
||
|
Bselections--;
|
||
|
dataRef=&dataB[remainingChoices[arrInd]-12];
|
||
1 year ago
|
}
|
||
1 year ago
|
selection.totalEX+=dataRef->ex1;
|
||
|
remainingChoices.erase(remainingChoices.begin()+arrInd);
|
||
|
for(int a2=0;a2<23;a2++){
|
||
|
Selection selection2 = selection;
|
||
|
int Aselections2=Aselections,Bselections2=Bselections;
|
||
|
std::vector<int>remainingChoices2 = remainingChoices;
|
||
|
int arrInd=a2;
|
||
|
if(Aselections2==0&&remainingChoices2[a2]<12||Bselections2==0&&remainingChoices2[a2]>=12)continue;
|
||
|
selection2.selectedScore.push_back({0,remainingChoices2[arrInd]});
|
||
|
if(remainingChoices2[arrInd]<12){
|
||
|
Aselections2--;
|
||
|
dataRef=&dataA[remainingChoices2[arrInd]];
|
||
1 year ago
|
}else{
|
||
1 year ago
|
Bselections2--;
|
||
|
dataRef=&dataB[remainingChoices2[arrInd]-12];
|
||
1 year ago
|
}
|
||
1 year ago
|
selection2.totalEX+=dataRef->ex1;
|
||
|
remainingChoices2.erase(remainingChoices2.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection2.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*10)continue;
|
||
|
for(int a3=0;a3<22;a3++){
|
||
|
Selection selection3 = selection2;
|
||
|
std::vector<int>remainingChoices3 = remainingChoices2;
|
||
|
int Aselections3=Aselections2,Bselections3=Bselections2;
|
||
|
int arrInd=a3;
|
||
|
if(Aselections3==0&&remainingChoices3[a3]<12||Bselections3==0&&remainingChoices3[a3]>=12)continue;
|
||
|
selection3.selectedScore.push_back({0,remainingChoices3[arrInd]});
|
||
|
if(remainingChoices3[arrInd]<12){
|
||
|
Aselections3--;
|
||
|
dataRef=&dataA[remainingChoices3[arrInd]];
|
||
|
}else{
|
||
|
Bselections3--;
|
||
|
dataRef=&dataB[remainingChoices3[arrInd]-12];
|
||
|
}
|
||
|
selection3.totalEX+=dataRef->ex1;
|
||
|
remainingChoices3.erase(remainingChoices3.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection3.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*9)continue;
|
||
|
for(int a4=0;a4<21;a4++){
|
||
|
Selection selection4 = selection3;
|
||
|
std::vector<int>remainingChoices4 = remainingChoices3;
|
||
|
int Aselections4=Aselections3,Bselections4=Bselections3;
|
||
|
int arrInd=a4;
|
||
|
if(Aselections4==0&&remainingChoices4[a4]<12||Bselections4==0&&remainingChoices4[a4]>=12)continue;
|
||
|
selection4.selectedScore.push_back({0,remainingChoices4[arrInd]});
|
||
|
if(remainingChoices4[arrInd]<12){
|
||
|
Aselections4--;
|
||
|
dataRef=&dataA[remainingChoices4[arrInd]];
|
||
|
}else{
|
||
|
Bselections4--;
|
||
|
dataRef=&dataB[remainingChoices4[arrInd]-12];
|
||
|
}
|
||
|
selection4.totalEX+=dataRef->ex1;
|
||
|
remainingChoices4.erase(remainingChoices4.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection4.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*8)continue;
|
||
|
for(int b1=0;b1<20;b1++){
|
||
|
Selection selection5 = selection4;
|
||
|
std::vector<int>remainingChoices5 = remainingChoices4;
|
||
|
int Aselections5=Aselections4,Bselections5=Bselections4;
|
||
|
int arrInd=b1;
|
||
|
if(Aselections5==0&&remainingChoices5[b1]<12||Bselections5==0&&remainingChoices5[b1]>=12)continue;
|
||
|
selection5.selectedScore.push_back({1,remainingChoices5[arrInd]});
|
||
|
if(remainingChoices5[arrInd]<12){
|
||
|
Aselections5--;
|
||
|
dataRef=&dataA[remainingChoices5[arrInd]];
|
||
|
}else{
|
||
|
Bselections5--;
|
||
|
dataRef=&dataB[remainingChoices5[arrInd]-12];
|
||
|
}
|
||
|
selection5.totalEX+=dataRef->ex2;
|
||
|
remainingChoices5.erase(remainingChoices5.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection5.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*7)continue;
|
||
|
for(int b2=0;b2<19;b2++){
|
||
|
Selection selection6 = selection5;
|
||
|
std::vector<int>remainingChoices6 = remainingChoices5;
|
||
|
int Aselections6=Aselections5,Bselections6=Bselections5;
|
||
|
int arrInd=b2;
|
||
|
if(Aselections6==0&&remainingChoices6[b2]<12||Bselections6==0&&remainingChoices6[b2]>=12)continue;
|
||
|
selection6.selectedScore.push_back({1,remainingChoices6[arrInd]});
|
||
|
if(remainingChoices6[arrInd]<12){
|
||
|
Aselections6--;
|
||
|
dataRef=&dataA[remainingChoices6[arrInd]];
|
||
|
}else{
|
||
|
Bselections6--;
|
||
|
dataRef=&dataB[remainingChoices6[arrInd]-12];
|
||
|
}
|
||
|
selection6.totalEX+=dataRef->ex2;
|
||
|
remainingChoices6.erase(remainingChoices6.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection6.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*6)continue;
|
||
|
for(int b3=0;b3<18;b3++){
|
||
|
Selection selection7 = selection6;
|
||
|
std::vector<int>remainingChoices7 = remainingChoices6;
|
||
|
int Aselections7=Aselections6,Bselections7=Bselections6;
|
||
|
int arrInd=b3;
|
||
|
if(Aselections7==0&&remainingChoices7[b3]<12||Bselections7==0&&remainingChoices7[b3]>=12)continue;
|
||
|
selection7.selectedScore.push_back({1,remainingChoices7[arrInd]});
|
||
|
if(remainingChoices7[arrInd]<12){
|
||
|
Aselections7--;
|
||
|
dataRef=&dataA[remainingChoices7[arrInd]];
|
||
|
}else{
|
||
|
Bselections7--;
|
||
|
dataRef=&dataB[remainingChoices7[arrInd]-12];
|
||
|
}
|
||
|
selection7.totalEX+=dataRef->ex2;
|
||
|
remainingChoices7.erase(remainingChoices7.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection7.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*5)continue;
|
||
|
for(int b4=0;b4<17;b4++){
|
||
|
Selection selection8 = selection7;
|
||
|
std::vector<int>remainingChoices8 = remainingChoices7;
|
||
|
int Aselections8=Aselections7,Bselections8=Bselections7;
|
||
|
int arrInd=b4;
|
||
|
if(Aselections8==0&&remainingChoices8[b4]<12||Bselections8==0&&remainingChoices8[b4]>=12)continue;
|
||
|
selection8.selectedScore.push_back({1,remainingChoices8[arrInd]});
|
||
|
if(remainingChoices8[arrInd]<12){
|
||
|
Aselections8--;
|
||
|
dataRef=&dataA[remainingChoices8[arrInd]];
|
||
|
}else{
|
||
|
Bselections8--;
|
||
|
dataRef=&dataB[remainingChoices8[arrInd]-12];
|
||
|
}
|
||
|
selection8.totalEX+=dataRef->ex2;
|
||
|
remainingChoices8.erase(remainingChoices8.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection8.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*4)continue;
|
||
|
for(int c1=0;c1<16;c1++){
|
||
|
Selection selection9 = selection8;
|
||
|
std::vector<int>remainingChoices9 = remainingChoices8;
|
||
|
int Aselections9=Aselections8,Bselections9=Bselections8;
|
||
|
int arrInd=c1;
|
||
|
if(Aselections9==0&&remainingChoices9[c1]<12||Bselections9==0&&remainingChoices9[c1]>=12)continue;
|
||
|
selection9.selectedScore.push_back({2,remainingChoices9[arrInd]});
|
||
|
if(remainingChoices9[arrInd]<12){
|
||
|
Aselections9--;
|
||
|
dataRef=&dataA[remainingChoices9[arrInd]];
|
||
|
}else{
|
||
|
Bselections9--;
|
||
|
dataRef=&dataB[remainingChoices9[arrInd]-12];
|
||
|
}
|
||
|
selection9.totalEX+=dataRef->ex3;
|
||
|
remainingChoices9.erase(remainingChoices9.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection9.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*3)continue;
|
||
|
for(int c2=0;c2<15;c2++){
|
||
|
Selection selection10 = selection9;
|
||
|
std::vector<int>remainingChoices10 = remainingChoices9;
|
||
|
int Aselections10=Aselections9,Bselections10=Bselections9;
|
||
|
int arrInd=c2;
|
||
|
if(Aselections10==0&&remainingChoices10[c2]<12||Bselections10==0&&remainingChoices10[c2]>=12)continue;
|
||
|
selection10.selectedScore.push_back({2,remainingChoices10[arrInd]});
|
||
|
if(remainingChoices10[arrInd]<12){
|
||
|
Aselections10--;
|
||
|
dataRef=&dataA[remainingChoices10[arrInd]];
|
||
|
}else{
|
||
|
Bselections10--;
|
||
|
dataRef=&dataB[remainingChoices10[arrInd]-12];
|
||
|
}
|
||
|
selection10.totalEX+=dataRef->ex3;
|
||
|
remainingChoices10.erase(remainingChoices10.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection10.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX)*2)continue;
|
||
|
for(int c3=0;c3<14;c3++){
|
||
|
Selection selection11 = selection10;
|
||
|
std::vector<int>remainingChoices11 = remainingChoices10;
|
||
|
int Aselections11=Aselections10,Bselections11=Bselections10;
|
||
|
int arrInd=c3;
|
||
|
if(Aselections11==0&&remainingChoices11[c3]<12||Bselections11==0&&remainingChoices11[c3]>=12)continue;
|
||
|
selection11.selectedScore.push_back({2,remainingChoices11[arrInd]});
|
||
|
if(remainingChoices11[arrInd]<12){
|
||
|
Aselections11--;
|
||
|
dataRef=&dataA[remainingChoices11[arrInd]];
|
||
|
}else{
|
||
|
Bselections11--;
|
||
|
dataRef=&dataB[remainingChoices11[arrInd]-12];
|
||
|
}
|
||
|
selection11.totalEX+=dataRef->ex3;
|
||
|
remainingChoices11.erase(remainingChoices11.begin()+arrInd);
|
||
|
if(bestSelections.size()>0&&selection11.totalEX<bestSelections.back().totalEX-(sortedChoices.front()<12?dataA[sortedChoices.front()].totalEX:dataB[sortedChoices.front()].totalEX))continue;
|
||
|
for(int c4=0;c4<13;c4++){
|
||
|
Selection selection12 = selection11;
|
||
|
std::vector<int>remainingChoices12 = remainingChoices11;
|
||
|
int Aselections12=Aselections11,Bselections12=Bselections11;
|
||
|
int arrInd=c4;
|
||
|
if(Aselections12==0&&remainingChoices12[c4]<12||Bselections12==0&&remainingChoices12[c4]>=12)continue;
|
||
|
selection12.selectedScore.push_back({2,remainingChoices12[arrInd]});
|
||
|
if(remainingChoices12[arrInd]<12){
|
||
|
Aselections12--;
|
||
|
dataRef=&dataA[remainingChoices12[arrInd]];
|
||
|
}else{
|
||
|
Bselections12--;
|
||
|
dataRef=&dataB[remainingChoices12[arrInd]-12];
|
||
|
}
|
||
|
selection12.totalEX+=dataRef->ex3;
|
||
|
if(bestSelections.size()>0){
|
||
|
int bestEX=bestSelections.back().totalEX;
|
||
|
if(selection12.totalEX>bestEX){
|
||
|
std::cout<<"New best EX combination found: "+std::to_string(selection12.totalEX)+". Selections are:"<<std::endl<<"\t";
|
||
|
for(std::pair<int,int>&song:selection12.selectedScore){
|
||
|
std::cout<<"P"<<song.first<<"|"<<song.second<<",";
|
||
|
}
|
||
|
std::cout<<std::endl;
|
||
|
bestSelections.push_back(selection12);
|
||
|
}
|
||
|
}else{
|
||
|
bestSelections.push_back(selection12);
|
||
|
std::cout<<"New best EX combination found: "+std::to_string(selection12.totalEX)+". Selections are:"<<std::endl<<"\t";
|
||
|
for(std::pair<int,int>&song:selection12.selectedScore){
|
||
|
std::cout<<"P"<<song.first<<"|"<<song.second<<",";
|
||
|
}
|
||
|
std::cout<<std::endl;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
1 year ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
std::cout<<"Done"<<std::endl;
|
||
1 year ago
|
}
|