Decrypting a string (water problem)

Source: Internet
Author: User

Pass the note. Time limit:1000ms Memory limit:65536k have questions? Dot here ^_^ Topic Description Narration

note-passing is an old way of conveying information in the classroom, though today's mobile phone messages and QQ chatting is becoming more and more popular, but handwritten messages can make people feel a sense of intimacy. For many students, it is an exciting way to pass the time, especially in some boring classrooms, to send some private information in school.

XX and the YY often pass a note in a self-study class to convey some privacy information.

But their seats are far apart, passing notes to reach each other through other people's abilities. In the transmission process, there will inevitably be some curiosity more powerful students peek at the content of the note.

So they thought of a way. Encrypt the contents of the note.

Encryption rules are easy: add two of the same letters at any point in the information, any number of times.

Because the use of English communication seems more high-end. So their note content is only in English.

Now give you the information after the encryption. Please restore the original content.

Input

first behavior of input data oneisinteger t (t≤). Indicates co-ownershipTGroup test Data.

next T Line. Each behavior is a string. The string includes only lowercase English letters, and guarantees that the original string does not include two adjacent identical characters , and that the string length does not exceed 200000.

Output

Each set of data outputs a line of string that represents the restored content.

Demo sample Input
1ssilofaafveuuu
Demo sample Output
Iloveu
TipsExample Explanation:

Delete AA after that, there was another FF , FF also be removed.

SOURCE "Division Chuang Cup" Shandong University of Technology Fifth annual ACM Program design Contest
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include < cctype> #include <cmath> #include <string>using  namespace Std;int main () {Ios::sync_with_stdio ( FALSE); int t,i,j; Char  s[1000001],s1[1000001]; cin>>t; while (t--) {cin>>s1; int len=strlen (S1); I=j=0;while (I<len) { if (i!=len-1&&s1[i]==s1[i+1]) I+=2;else if (S1[i]==s[j-1]) {j--;i++;} elses[j++]=s1[i++];} S[j]= ';cout<<s<<endl; } return 0;}


Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

Decrypting a string (water problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.