Something like this. What you want is to get the hash of any substring in quick (like O(1)) time, then you can just try every length, so the complexity would be O(N) to hash and O(1) per O(N) lengths, leading to O(N) in total.
Now test cases have been changed. At the time of contest if you would have done it by applying substr in a little optimized way yours would have passed as well. Test cases were weak so brute force solutions also passed.
Don’t make vectors of lengths rather use loop only:
int k =( len-2) /2
string b1, b2, c1, c2;
b1=s.substr(0, i) ;
b2=s.substr(i, i) ;
// do c1 c2 as well and compare b1, b2 and c1, c2
Your code consumes some extra time in vector operations and substring can be made only 4 times. It would have been accepted.