prrateekk's blog

By prrateekk, history, 8 years ago, In English

how are we supposed to solve this problem?

https://www.codechef.com/AMR16MOS/problems/AMR16J

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Each balanced parenthesis sequence can be reduced to an equivalent nim piles using the following rules. Let *A denote the nim value of balanced sequence A. *() = 1 *(A) = *A + 1 *AB = *A ^ *B So just find the nim value of the given sequence. If it is 0, then it is a losing position for the first player, else winning. :)