Question link: Sherlock and Inversions | Practice Problems
Solution Link : XoFsHQ - Online C++0x Compiler & Debugging Tool - Ideone.com
Getting TLE!
I have applied mo’s Algorithm and segment tree.
How to optimize it further??
Question link: Sherlock and Inversions | Practice Problems
Solution Link : XoFsHQ - Online C++0x Compiler & Debugging Tool - Ideone.com
Getting TLE!
I have applied mo’s Algorithm and segment tree.
How to optimize it further??
The best possible solution is to use iterative segment tree. I modified your code for it and it passed under the time limit .
link for
(https://ideone.com/j7kD2a)
Instead of segment tree use BIT/Fenwick tree
MY AC CODE kC1nTX - Online C++ Compiler & Debugging Tool - Ideone.com