All submissions for this problem are available.
Thomas Anderson is a computer programmer who maintains a double life as "Neo" the hacker. Another hacker named Trinity contacts Neo and informs him that a man named Morpheus can tell him the meaning of "the Matrix", a cryptic phrase that Neo has encountered repeatedly online; however, three dark-suited Agents, led by Agent Smith, appear determined to prevent them meeting. Undeterred, Neo eventually meets Morpheus, who warns him that once he knows the truth, he will not be able to return to his normal life. Neo indicates his acceptance by choosing to swallow an offered red pill. His reality soon disintegrates and he abruptly wakes, naked and weak, in a liquid-filled vessel, finding himself as one of billions of people connected by cables to an elaborate electrical system. Morpheus explains that in the 21st century, humans waged a war against intelligent machines they had created. When humans blocked the machines' access to solar energy, the machines instead turned to harvesting the humans' bioelectricity as a substitute power source, while keeping them trapped in the Matrix.
Morpheus have to hack into the Matrix and Unplug the enslaved humans. There is a display board attached to every vessel displaying a 4 digit value. It also has V buttons with a four digit number associated with it. Morpheus's secret agents had noticed when any of these buttons is pressed, the number associated with that button was added with the displayed value and so a new number was displayed. He also realised that after a particular number of presses the alarm starts ringing. Your task is to create a program that will help him to find that threshold after which the alarm will ring.
There are certain humans enslaved permanently,called the zivots.Also find the zivots so that Morpheus can save the rest and not waste time..
There will be at most 100 test cases. For each test case, there will be 3 numbers: L, U and R where
represents the current lock code, Urepresents the unlock
code and R represents the number of available buttons. After that, there are R numbers
in a line representing the value of buttons. The values of L, U, RVi will always be
denoted by a four digit number (even if it is by padding with leading zeroes). Input will be terminated
when L = U = R = 0..
For each test case, there will be one line of output which represents the serial of output followed by the
minimum number of button press required to unlock the lock. If it is not possible to unlock the lock,
then print a line ‘Zivot’ instead (without quotes).
L (0000 ≤ L ≤ 9999)
U (0000 ≤ U ≤ 9999)
R (1 ≤ R ≤ 10)
there are R numbers (0 ≤ RVi ≤ 9999)
Input: 0000 9999 1 1000 0000 9999 1 0001 5234 1212 3 1023 0101 0001 0 0 0 Output: Case 1: Zivot Case 2: 9999 Case 3: 48
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.