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

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

a+b+c
a+c+b
b+a+c
b+c+a
c+a+b
c+b+a

and remove overlaped character and take min length .

Check Code Here: “vYSd7G - Online C++0x Compiler & Debugging Tool - Ideone.com

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 : “Submission #88292214 - Codeforces