astrocoder's blog

By astrocoder, history, 8 years ago, In English

I'm exercising my dp skills and encountered topcoder SRM 694 dev1 250 problem. Can someone explain how to solve it?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

I solved it using DP[i][a][b][m] = can I reach state up to student i, where first group has xor sum a, second group has xor sum b and m is a mask that indicates the state for each of the three groups (empty / non empty). Note that sum of third group can be derived from sum of the other two by xoring them with the current prefix xor sum.