lostbrain's blog

By lostbrain, 7 years ago, In English

Hello everyone, I was trying this problem for some days.The idea was kind of simple.If the pair (x,y) has even parity then pair (0,x-1) and pair(0,y) will have same parity.If the pair(x,y) has odd parity then pair (0,x-1) and pair(0,y) will have different parity.I modeled the pairs to a graph.I defined two pairs to be adjacent if they have same parity.Then I used Depth First Search to spot any contradiction in the graph.I am certain that the algorithm is correct(Hopefully :P) but i am not sure why i am getting a Time Limit exceeding verdict.Is there a better idea or implementation to this problem ?? Please help me out. Here is my code

Read more »

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