in this case, we wanted to use Hash, change from MLE to re, and finally stay at tle. The key value is the sum of the midpoint coordinates, the linked list is used to solve the case where the key values are the same (collision). Finally, the sorting is complete.
# Include <iostream> <br/> using namespace STD; <br/> # include <cstdlib> <br/> struct point <br/>{< br/> int X, y; <br/>}; <br/> point P [1005], MP [500005]; <br/> int CMP (const void * a, const void * B) <br/> {<br/> point * P1 = (point *) A, * P2 = (point *) B; <br/> If (P1-> X = P2-> X) <br/> return P1-> Y-P2-> Y; <br/> else <br/> return P1-> X-P2-> X; <br/>}< br/> int main () <br/>{< br/> int ca, N, I, j, M, C, T; <br/> scanf ("% d", & Ca ); <br/> while (ca --) <br/>{< br/> m = 0; <br/> scanf ("% d", & N ); <br/> for (I = 1; I <= N; I ++) <br/> scanf ("% d", & P [I]. x, & P [I]. y); <br/> for (I = 1; I <= N; I ++) <br/> for (j = I + 1; j <= N; j ++) <br/>{< br/> MP [M]. X = P [I]. X + P [J]. x; <br/> MP [M]. y = P [I]. Y + P [J]. y; <br/> M ++; <br/>}< br/> qsort (MP, M, sizeof (MP [0]), CMP ); <br/> j = 1, C = 1, t = 0; <br/> while (j <m) <br/> {<br/> If (MP [J]. X = MP [J-1]. X & MP [J]. y = MP [J-1]. y) <br/> C ++; <br/> else <br/> {<br/> T + = C * (c-1)/2; <br/> C = 1; <br/>}< br/> J ++; <br/>}< br/> T + = C * (c-1) /2; <br/> printf ("% d/N", T); <br/>}< br/>}