voidinit(){ for(auto& item: indexMap) item.push_back({1,1}); for(int i =2; i !=6;++i) indexMap[i].push_back({1,2}); for(int i =3; i !=6;++i) indexMap[i].push_back({2,2}); for(int i =4; i !=6;++i) indexMap[i].push_back({1,3}); indexMap[5].push_back({2,3}); }
voidinit(){ for(auto& item: indexMap) item.emplace_back(2,1); for(int i =2; i !=6;++i) indexMap[i].emplace_back(3,1); for(int i =3; i !=6;++i) indexMap[i].emplace_back(4,2); for(int i =4; i !=6;++i) indexMap[i].emplace_back(4,1); indexMap[5].emplace_back(5,2); }
vector<pair<int,int>> indexMap[6]; int gInput[8]; int gLength =0;
voidinit(){ for(auto& item: indexMap) item.emplace_back(2,1); for(int i =2; i !=6;++i) indexMap[i].emplace_back(3,1); for(int i =3; i !=6;++i) indexMap[i].emplace_back(4,2); for(int i =4; i !=6;++i) indexMap[i].emplace_back(4,1); indexMap[5].emplace_back(5,2); }
boolmove(vector<int>& record,int index,int length){ if(index ==-1)returnfalse; int maxIndex =int(length -(record.size()- index -1)); if(++record[index]!= maxIndex)returntrue; if(!move(record, index -1, length))returnfalse; record[index]= record[index -1]+1; returntrue; }
boolcheck(int a,int b,int c){ return(a + b > c)&&(a + c > b)&&(b + c)> a; }
doublecalculate(int a,int b,int c){ double p =(a + b + c)/2.0; returnsqrt(p *(p - a)*(p - b)*(p - c)); }
double ans =0;
voidforEachMap(vector<pair<int,int>>& map, vector<int>& list,int length){ int sum =0; for(constauto& item: list) sum += gInput[item]; for(constauto& item: map){ select(item.first, length,[&](const vector<int>& selected){ int allSum =0; for(constauto& index: selected) allSum += gInput[list[index]]; select(item.second,int(selected.size()),[&](const vector<int>& inner){ int a =0; for(constauto& index: inner) a += gInput[list[selected[index]]]; int b = allSum - a; int c = sum - allSum; if(check(a, b, c)) ans =max(ans,calculate(a, b, c)); }); }); } }