problem link : Problem - 798B - Codeforces
I don’t understand the editorial of this problem as I am new to dp. A thorough explanation would be very very helpful.
editorial link:
Codeforces Round #410 (Div. 2) Editorial - Codeforces
problem link : Problem - 798B - Codeforces
I don’t understand the editorial of this problem as I am new to dp. A thorough explanation would be very very helpful.
editorial link:
Codeforces Round #410 (Div. 2) Editorial - Codeforces
I haven’t seen the editorial but here is an easy solution which I can see :
1)All the strings should be rotation of each-other .
2)So just pick up the first string and see if all other strings are its rotations or not.
3)If all are the rotations, then go to step-4, else print “-1”
4)Say the first string is “abcdef”
5)Aim for:- “abcdef” and calculate the total cost .
6)Then aim for :- “bcdefa”…and do the same.
7)In short aim for all the possible rotations, and calculate their cost .
8)Minimum of all these costs is your answer