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

Why I WA 6
Posted by Zachary 1 Apr 2012 19:10
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 250009;
char s[N];

int main()
{
    scanf("%s", s);
    int len, i, j;
    len = strlen(s);
    for (i = 1, j = 0; i < len; ++i) {
        if (s[i] == s[j]) {
            s[i] = 96;
            s[j] = 96;
            i++;
            while (s[j] == 96)  j--;
            while (j>=0 && i<len && s[i] == s[j]) {
                s[j] = 96;
                s[i] = 96;
                j--;
                i++;
            }
            j = i;
        }
        else
            j = i;
    }
    for (i = 0; i < len; ++i)
        if (s[i] != 96)
            printf("%c", s[i]);
    printf("\n");
    return 0;
}