1866C - Completely Searching for Inversions
What is leading my solution to go memory limit exceeded? Please Help. And Can Anybody give hint about the correct approach. I am going with the complete brute force approach of calculating the Z Array and then finding the number of inversion in linear time. I was calculating the Z Array according to the given question.
The array can become extremely big (for example, if the graph is dense).
Hint: try to compute the size of $$$Z$$$ first. Then, use a similar approach to count the inversions.