ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1654. Cipher Message

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];
}

}
Posted by BillSu 26 Apr 2014 15:15
Good codes
Posted by Nikita Semenov[Kungur] 27 Oct 2015 23:34
I use stack and my solution works 0.064s :)