CipherProblem code: KNIGHT05 |
M ller tried to catch Stierlitz red-handed many times, but always failed because Stierlitz could ever find some excuse. Once Stierlitz was looking through his email messages. At that moment, M ller entered secretly and watched a meaningless sequence of symbols appear on the screen. "A cipher message," M ller thought. "UTF-8," Stierlitz thought. It is known that Stierlitz ciphers messages by the following method. He deletes all spaces and punctuation marks. He replaces all successive identical letters by one such letter. He inserts two identical letters at an arbitrary place many times. Try to restore a message as it was after the second step. For that, remove from the message all pairs of identical letters inserted at the third step.
Input
The first line of input contains number of test cases t<=10000. The next input line for each test case contains a message ciphered by Stierlitz. The message consists of lowercase English letters and its length is at most 200000.
Output
Output the restored message
Example
Input: 3 wwstdaadierfflitzzz ravi maggon '''hihiiih Output: stierlitz ravimaon hihih
| Author: | Chunky |
| Date Added: | 22-08-2010 |
| Time Limit: | 5 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

Don't
Don't use
#include<iostream.h> and void main()
instead use
#include<iostream>
using namespace std;
int main()
{
}
why is the input # 3
why is the input # 3 containing special characters??
it is said tht input contains lowercase english letters
what all characters will be
what all characters will be considered as ppunctuaion marks..???
punctuation marks are those
punctuation marks are those that are considered in normal English Grammar
@Chetan: do read the
@Chetan: do read the problem statement correctly. It says that you need to remove spaces and punctuation marks from a string in lower case english letters.
Step 1 : "He deletes all
Step 1 : "He deletes all spaces and punctuation marks."
Step 2 : "He replaces all successive identical letters by one such letter."
Step 3 : "He inserts two identical letters at an arbitrary place many times."
I think that the ciphered message shouldn't contain any space or punctuation, and we are given ciphered message, i suppose, as input.
Correct me if I am wrong.
@chetan : your are right
@chetan : your are right you need to decode the ciphered message i.e. what actually was the string which was afftected you need to find that string.
Hey Guys If you are
Hey Guys
If you are participating in this event but not registered on the website http://aranyatech.org/kc.php do it so that we will consider you for our grading of this event.
@ravi: u have given cipheres
@ravi:
u have given cipheres text as input but ur input "ravi maggon" contains a space...which must have been deleted in the first step.. ??
+1 Lokesh also in 3rd case
+1 Lokesh
also in 3rd case there shouldnt be any punctuation characters
hey guys u r misunderstanding
hey guys u r misunderstanding the problem.....actually the ciphered text will be given as input and you have to trace back the actual string that was affected.
@Ravi The question says that
@Ravi
The question says that input is an encrypted string (i.e the message after third step). And the encryption technique says that
1) remove all punctuations and spaces
2)replace all identical letters with one such letter
3) insert two identical letters at arbitrary place many times.
Now the problem in test cases is that in test case 2 and 3 there is a space and punctuations respectively.
If the above steps are followed then it is impossible to get a encrypted message with punctuations and space. Thus test cases 2 and 3 are wrong.
Please tell where i am going wrong in understanding the problem.
+1 Lokesh +1 Anvay +1
+1 Lokesh
+1 Anvay
+1 Chetan
Inputs 2 and 3 cannot be encrypted messages..
@Ravi
Please clear the doubts ...
@Lokesh: How come you have a
@Lokesh: How come you have a successful submission when the question in wrong? Can you please clarify the question if you know what it exactly is....since u have solved it
@Ravi : Please take a look at the question yourself. The last 2 cases are wrong. They cannot be the ciphered code since they have a space and punctuation
could you please provide some
could you please provide some more cases???
admins, I think that the
admins, I think that the doubt everyone is having is very genuine. If the input is cipher text then it can't have spaces and punctuation marks and thus test-cases 2 & 3 are invalid. Please reply asap.
@those who have succesfully
@those who have succesfully submitted solutions : how have you interpreted the question?
my code is working for every
my code is working for every test case i can think of but i am getting wrong answer plz tell if any test cases for which it may not work
hilarious to see that people
hilarious to see that people have got successful submissions for a wrongly framed problem :)
@shreya and 70% of them are
@shreya and 70% of them are from Thapar. STRANGE !
I am explaining the test
I am explaining the test cases:
For a given input like wwwwwtttttssss abcd
to get output: remove spaces,remove consecutive occurence with single character
so output becomes: wtsabcd
@Ravi : By saying "remove
@Ravi : By saying "remove consecutive occurrence with single character", do u mean we should REPLACE it with a single character? because that is what you are doing in this example.
And does this mean the above 3 test cases are all wrong? Because if we consider this, the test cases are wrong...and can their be punctuation marks in the input?
PS: please properly construct your problem statements the next time you plan to hold a coding competition.
Considering that u typed the
Considering that u typed the above test case without any mistakes,
your explaination totally contradicts the problem statement.
Since , 's' (quotes for clarity only) appears EVEN number of times , obviously it was added in PAIRS of TWO in the process of ciphering , hence while deciphering we would remove all 's' thus answer should be wtabcd.
The Funny part is , that u are still adamant at giving SPACES and PUNCTUATIONS in the input :)
@Rajat : Though I am not sure
@Rajat : Though I am not sure what goes on in his mind, I think by saying "remove consecutive occurrence" he meant "REPLACE consecutive occurrence with single character"
Anyway, even that gives a wrong answer flag. I am still wondering how the 10 people were able to submit solutions successfully. :)
To all whose program has been
To all whose program has been accepted: What will your program o/p for the test case that Ravi Maggon has just mentioned wwwwwtttttssss abcd
@shrey & Ravi > How does
@shrey & Ravi > How does letter 'a' (quotes for clarity) vanishes in example 1 if we only have to replace consecutive occurance with single letter.
Please don't take this otherwise.
Your Problem Statement is definetely faulty, unclear, poorly framed and written unthoughtfully. This problem has occured because Problem writter has considered many things as obvious. If you hesitate to reply to genuine queries then it's a big Question mark on genuineness of the event.
@rajat: may be you are right.
@rajat: may be you are right. Thats why I clarified in my comments by taking an example.
plz... do clarify the
plz... do clarify the problem...
Are the examples given in the questions correct??
If not give the correct examples soon..
@Ravi > again don't take it
@Ravi > again don't take it otherwise, but you have a big misconception that u have clarified the doubt by your example.
Its a complete waste of
Its a complete waste of time..... trying a question about which even the proposer of the question is not clear.
Questions has got different meaning, the test cases given do not concur with that meaninig and, when the admin himself explains the meaning of a test case, it is also different from the previous two meanings.
WTF is going on.
And i cud not understand why 70-80 percent of the persons who solved the question are from thapar itself. C'mon, i hv considered every bit of possible senario in which my prog can fail, but still it fails on submission.
We request Admin to please clear the meaning of the ques. out of the two set of test cases provided
set1: 3 cases given in the ques.
set2: 1 case given later.
which one should we consider as the meaning conveyed by the question?
@Ravi : Dude, which branch
@Ravi : Dude, which branch are you from ? Earthquake Engineering? No wait, even they would see whats wrong with the question. Offence meant. This is professional coding and not some local competition for your college guys. So for the last time, either write the full question again clarifying everything, or stop holding these coding competitions. I am sorry to say all this, but there is a limit to foolishness.
And we would be glad if you'd stop clarifying the questions to people from your college only and shed some light on it for us as well.
Look i am giviny you the
Look i am giviny you the logic of what exactly you have to do.
From a given input
1.remove the spaces
2.if something occurs twice remove that but if something occurs more than 2 times you should save its one occurence.
3. remove all punctuation marks from the input.
my program is satisfying all
my program is satisfying all the test cases.....but it is still being evaluated as a wrong answer
giver some more testcases
giver some more testcases
wht the hell..!! prog. is
wht the hell..!! prog. is taking all cases on my compiler but still getting wrong answer after submission.....
give some more good test
give some more good test cases.....
Seriously, this has been very
Seriously, this has been very irresponsible behaviour on the admin's part. Why does it take so long to answer to the queries.
Also, the logic given in the comment by Mr. Ravi doesn't match with the question statement itself.
According to the logic given, if we consider the steps in order then, say for
input: aa ''abc
After first step (removing spaces), we get: aa"abc
After removing duplicates: a"abc
After removing punctuations: aabc
On the other hand, if you go by the problem statement, then the punctuations would be removed first and the output would be:
abc
Would anyone like to answer this??
My bad. Consider the above
My bad. Consider the above test case as : aaa "abc