Need help on the implementation of UVA 10604 — Chemical Reaction

Revision en2, by isat1729, 2016-05-05 00:24:38

My idea is say the tube has 1,2,2,3 so I will try out (1,2), suppose their combination produces 2, now I've two options, taking 2 (which I got from (1,2)) and combine it with either 2 or 3 (from the remaining tubes) or combining remaining tubes (2,3), get their combination and try out with 2. Afterwards, I'll try out another combination from the beginning and this goes on.

Initially, I overlooked the fact that I can try out combinations from tubes remaining despite using one of the reagents from the combination formed from two tubes. So, I coded a solution, of course it is buggy. But now I am facing problems in implementing what I just have explained. Any help is really appreciated.

Problem link: https://uva.onlinejudge.org/external/106/10604.pdf

Buggy solution link: http://ideone.com/h2nMTX

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English isat1729 2016-05-05 00:24:38 4 Tiny change: '0604.pdf\nBuggy so' -
en1 English isat1729 2016-05-05 00:24:03 877 Initial revision (published)