All submissions for this problem are available.
Election commision is decrypting the communication channels of both the party to check cash for vote. All the communication is done by binary code and are encrypted as follows:
Say the message is 0111, encryption will be to each digit the sum of its adjacent digits and itself. So encrypted message will be 1232.
So if M is the message and E is the encrypted message, then E[i] = M[i-1] + M[i] + M[i+1] for all digit positions i. Characters off the left and right edges of the string are treated as zeroes. To decrypt, we can assume the first digit as 0 or 1.
Eg: In the above encrypted message 1232, Assuming the first digit as 0 gives the message as 0111 and assuming the first digit as 1 does not give a valid binary message. Given the encrypted message, print the decrypted messages assuming the first digit as both 0 and 1 (in the order). If the given encrypted message is invalid, print “NONE” (without quotes)or print the decrypted message.
- First line contains the encrypted message E.
- Output the message considering 0 as first digit in first line.
- Output the message considering 1 as first digit in second line.
- Print NONE if any of the case gives an invalid message
- Encrypted message, E will have a maximum of 30 digits
- Each digit in E will be between 0 and 9 inclusive.
|Time Limit:||- 1 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.