LInk to problem : https://www.codechef.com/MAY17/problems/WSITES01/
My sol : http://ideone.com/x04NBs
In subtask 2 only 13,14 are showing TLE
It shows TLE, How can i optimize it further??
EDIT : I am trying to put (+) sites in one structure and (-) sites in another structure
and for each (-) site i am comparing all (+) sites and then putting longest continous pattern for a (-) site
from all (+) site to another structure.
In worst case we can have 10^3 (+) sites and 10^2 (-) sites making time complexity O(10^5).
So why i am getting TLE?