Jump to content

Parity Disjoint Set Problem

- - - - -

  • Please log in to reply
No replies to this topic

#1
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
I'm currently trying to solve the following programming problem:
Timus Online Judge. Problem 1003

Quote

Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth digit inclusively) and ask him, whether this subsequence contains even or odd number of ones. Your friend answers your question and you can ask him about another subsequence and so on.

Your task is to guess the entire sequence of numbers. You suspect some of your friend's answers may not be correct and you want to convict him of falsehood. Thus you have decided to write a program to help you in this matter. The program will receive a series of your questions together with the answers you have received from your friend. The aim of this program is to find the first answer which is provably wrong, i.e. that there exists a sequence satisfying answers to all the previous questions, but no such sequence satisfies this answer.

I've read that this problem is best approached using disjoint sets but I cannot see how.
I was originally trying to add(union) even groups of 1's to one tree and odd groups of 1's to another tree. (arbitrarily to see if I could lead myself to a feasible solution)
Using this idea, I have come up with nothing. :crying:

Can anyone provide any advice on how I can approach this problem?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users