CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Aranya 2010 Challenge » Cipher

Cipher

Problem code: KNIGHT05

  • All Submissions

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


  • Submit

Comments

  • Login or Register to post a comment.

Don't

maggonravi @ 1 Sep 2010 06:09 PM

Don't use

#include<iostream.h> and void main()

instead use

#include<iostream>

using namespace std;

int main()

{

}

why is the input # 3

chetan1507 @ 1 Sep 2010 06:09 PM

why is the input # 3 containing special characters??
it is said tht input contains lowercase english letters

what all characters will be

saurabh075 @ 1 Sep 2010 06:49 PM

what all characters will be considered as ppunctuaion marks..???

punctuation marks are those

maggonravi @ 1 Sep 2010 06:56 PM

punctuation marks are those that are considered in normal English Grammar

@Chetan:   do read the

maggonravi @ 1 Sep 2010 06:57 PM

@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

chetan1507 @ 1 Sep 2010 07:08 PM

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

maggonravi @ 1 Sep 2010 07:16 PM

@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

maggonravi @ 1 Sep 2010 07:55 PM

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

lokesh198 @ 1 Sep 2010 08:24 PM

@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

chetan1507 @ 1 Sep 2010 08:45 PM

+1 Lokesh

also in 3rd case there shouldnt be any punctuation characters

hey guys u r misunderstanding

maggonravi @ 1 Sep 2010 08:48 PM

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

anvaysri @ 1 Sep 2010 09:49 PM

@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

simar.i3r @ 1 Sep 2010 10:09 PM

+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

rockingsa1991 @ 1 Sep 2010 10:51 PM

@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

dabbcomputers @ 1 Sep 2010 11:38 PM

could you please provide some more cases???

admins, I think that the

diligents @ 2 Sep 2010 12:03 AM

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

rockingsa1991 @ 2 Sep 2010 12:11 AM

@those who have succesfully submitted solutions : how have you interpreted the question?

my code is working for every

vikashdc @ 2 Sep 2010 10:08 AM

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

rockingsa1991 @ 2 Sep 2010 01:15 PM

hilarious to see that people have got successful submissions for a wrongly framed problem :)

@shreya and 70% of them are

rajat_mathur @ 2 Sep 2010 02:14 PM

@shreya and 70% of them are from Thapar. STRANGE !

I am explaining the test

maggonravi @ 2 Sep 2010 02:48 PM

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

rockingsa1991 @ 2 Sep 2010 03:25 PM

@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

rajat_mathur @ 2 Sep 2010 03:25 PM

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

rockingsa1991 @ 2 Sep 2010 03:32 PM

@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

cybersharp @ 2 Sep 2010 04:26 PM

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

rajat_mathur @ 2 Sep 2010 05:43 PM

@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.

maggonravi @ 2 Sep 2010 05:46 PM

@rajat: may be you are right. Thats why I clarified in my comments by taking an example.

plz... do clarify the

codecracker @ 2 Sep 2010 06:00 PM

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

rajat_mathur @ 2 Sep 2010 06:16 PM

@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

kunalsangwan @ 2 Sep 2010 06:16 PM

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

rockingsa1991 @ 2 Sep 2010 06:26 PM

@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

maggonravi @ 2 Sep 2010 06:42 PM

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

varunsapra @ 2 Sep 2010 06:53 PM

my program is satisfying all the test cases.....but it is still being evaluated as a wrong answer

giver some more testcases

aki4it @ 2 Sep 2010 09:24 PM

giver some more testcases

wht the hell..!! prog. is

vishalgupta753 @ 2 Sep 2010 10:28 PM

wht the hell..!! prog. is taking all cases on my compiler but still getting wrong answer after submission.....

give some more good test

vishalgupta753 @ 2 Sep 2010 10:30 PM

give some more good test cases.....

Seriously, this has been very

diligents @ 3 Sep 2010 12:33 AM

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

diligents @ 3 Sep 2010 12:39 AM

My bad. Consider the above test case as : aaa "abc

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com