Result calculate(Flip_Flop* chn,bool** src,size_t* seq,size_t chnLength,size_t srcLength)
{
size_t changedArrayLength=srcLength*chnLength-1;
bool* changedArray=new bool[changedArrayLength];
size_t exeTime=0;
for(size_t i=0;i<srcLength;++i)
{
for(size_t j=0;j<chnLength-1;++j)
{
changedArray[exeTime]=src[i][seq[j]] ^ src[i][seq[j+1]];
exeTime++;
}
if(i!=srcLength-1)
{
changedArray[exeTime]=src[i][seq[chnLength-1]] ^ src[i+1][seq[0]];
exeTime++;
}
}
vector<TestCase*>* cases=new vector<TestCase*>((srcLength-1)*chnLength,NULL);
//vector<TestCase*> cases((srcLength-1)*chnLength);
//#pragma omp parallel for
for(int i=0;i<cases->size();i++)
{
double peakPower=0;
for(size_t j=0;j<chnLength;j++)
{
if(changedArray[i+j])
{
peakPower+=chn[chnLength-j-1].Power();
}
}
cases->at(i)=new TestCase(peakPower,i);
}
return Result(seq,cases);
}
UmVzdWx0IGNhbGN1bGF0ZShGbGlwX0Zsb3AqIGNobixib29sKiogc3JjLHNpemVfdCogc2VxLHNpemVfdCBjaG5MZW5ndGgsc2l6ZV90IHNyY0xlbmd0aCkKewogICAgc2l6ZV90IGNoYW5nZWRBcnJheUxlbmd0aD1zcmNMZW5ndGgqY2huTGVuZ3RoLTE7Cglib29sKiBjaGFuZ2VkQXJyYXk9bmV3IGJvb2xbY2hhbmdlZEFycmF5TGVuZ3RoXTsKCQoJc2l6ZV90IGV4ZVRpbWU9MDsKCWZvcihzaXplX3QgaT0wO2k8c3JjTGVuZ3RoOysraSkKCXsKCQlmb3Ioc2l6ZV90IGo9MDtqPGNobkxlbmd0aC0xOysraikKCQl7CgkJCWNoYW5nZWRBcnJheVtleGVUaW1lXT1zcmNbaV1bc2VxW2pdXSBeIHNyY1tpXVtzZXFbaisxXV07CgkJCWV4ZVRpbWUrKzsKCQl9CgkJaWYoaSE9c3JjTGVuZ3RoLTEpCgkJewoJCQljaGFuZ2VkQXJyYXlbZXhlVGltZV09c3JjW2ldW3Nlc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