Submission link: https://mirror.codeforces.com/contest/1292/submission/239863555
adj is going to use n long long int
dp, cnt, par : n^2 * 3
Each pair of vertices has unique distance so prs would also hold n*n long long int
Total = 4*n^2 = 4*(3*10^3)^2 = 36*10^6 long long int
1 long long int uses 8 Bytes so total = 36*10^6*8 Bytes = 288 * 10^6 Bytes = 288 Megabytes. Memory limit is 512 MB but still I am getting MLE.
Where am I wrong?