Rolling hash , Codeforces Beta Round #25 div2 E (solved)

Question : “
My approach: Make all combination of given three-string like


and remove overlaped character and take min length .

Check Code Here: “

forgiven input(check code) it gives 156 but the correct answer is 100

Please help @carre @galencolin @everule1

string 1 is a substring of string, and your code does not handle the answer for substrings

so how can I do this question using Rolling hash ?

You should ignore any strings which are a substring of another string.

mmmm…it’s gonna difficult for me …how can i ignore ?

Thanks bro , after struggling for an hour , just added 3 lines and it got AC

// agar pehele hi koi string dusri string ki substring hai to first string ko ignore kro
    if(a.find(b) != string::npos || c.find(b) != string::npos)
		b = "";
	if(a.find(c) != string::npos || b.find(c) != string::npos)
		c = "";
	if(b.find(a) != string::npos || c.find(a) != string::npos)
		a = "";

AC solution : “