ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1654. Cipher Message

0.109s answer
Posted by dula 24 Apr 2013 23:50
#include<iostream>
#include<string.h>
#include<deque>
#include<stdio.h>
using namespace std;
int main()
{
    string node;
    cin >> node;
    int one,two;
    one = 0;
    two = 1;
    int pre = 0;
    for(int i = 0;i < node.size();i++)
    {
        if(node[i] == '!')
        continue;
        if(node[i] == node[i+1])
        {
            node[i] = node[i+1] = '!';
            one = pre;
            if(i+2 < node.size())
            two = i+2;
            while(one> 0 && two < node.size())
            {
                while(one > 0 && node[one] == '!')
                one--;
                if(node[one] == node[two] )
                {
                    node[one] = node[two] = '!';
                    one--;two++;
                }
                else
                break;
            }
        }
        else
        pre = i;

    }

   for(int i = 0;i < node.size();i++)
   {
       if(node[i] != '!')
       cout << node[i];
   }

}
Re: 0.109s answer
Posted by BillSu 26 Apr 2014 15:15
Good codes
Re: 0.109s answer
Posted by Nikita Semenov[Kungur] 27 Oct 2015 23:34
I use stack and my solution works 0.064s :)
Re: 0.109s answer
Posted by ELDVN 8 Nov 2015 01:41
My solution works 0.048s ;)
Re: 0.109s answer
Posted by INSOOP 11 Mar 2019 01:06
Why your solutions is right?
if input is:
sddssdds
then your ans is "ss"!
Re: 0.109s answer
Posted by MelifiousSonder 12 Jun 2019 11:39
0.015, guys