Solution Explanation Needed for USACO Concurrently Balanced Strings (2012 Gold November Contest)

Problem: [][1]

Solution: [][2]

In the solution for this problem, I am confused as to what L, R, mp, and lft do in the program. My current thoughts are:
L: Maintains cumulative sum for each individual array
R: The index where a particular cumulative sum for a certain array was last seen
lft: Completely lost…
mp: Completely lost… What is the point of mp if only mp[L] is modified? Why is mp[L] incremented?

In addition, if my thoughts on L and R are correct, why are the indices set to i+1 instead of i?

Please help, and thanks in advance!



BUMP! BUMP! I would really like some help on this…