void QuickGroupSort(long long arr[], int low, int high, int nstep = 3)
{
if (high <= low) return;
int i = low;
int j = high + 1;
int key = arr[low*3+2];
while (true)
{
/*从左向右找比key大的值*/
while (arr[((++i)*nstep + nstep-1)] < key)
{
if (i == high) {
break;
}
}
/*从右向左找比key小的值*/
while (arr[((--j)*nstep+nstep-1)] > key)
{
if (j == low) {
break;
}
}
if (i >= j) break;
ExchangeValue(arr, i, j);
}
ExchangeValue(arr, low, j);
QuickGroupSort(arr, low, j - 1);
QuickGroupSort(arr, j + 1, high);
}
void ExchangeValue(long long arr[],int i,int j, int nstep = 3)
{
long long * tmp = new long long(nstep);
memcpy(tmp, &arr[i*nstep], sizeof(long long)*nstep);
memcpy(&arr[i*nstep], &arr[j*nstep], sizeof(long long)*nstep);
memcpy (&arr[j*nstep], tmp,sizeof(long long)*nstep);
}