Help needed in a String Related Problem

Revision en1, by MotaSanyal, 2019-10-14 20:54:41

Hi everyone!

I was trying to solve this problem which came in last year ICPC Gwalior-Pune Onsite Round.

My approach :

I first checked whether C is present either in A or in B, if so, then answer will be length(A) + length(B) Otherwise , found the longest prefix of C that occurs as a suffix of A (say, X) and longest suffix of C that occurs as prefix of B (say, Y). Then if X+Y <= length(C), answer will be length(A) + length(B) + (length(C) — (X+Y)) , else if X+Y > length(C), then answer is length(A) + length(B) + (length(C) — max(X,Y)).

The verdict I am getting is Wrong Answer. Can anyone please point out where am I going wrong?

Tags #help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English MotaSanyal 2019-10-14 20:54:41 752 Initial revision (published)