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

wa #4
Posted by gerson 29 Aug 2016 12:00
hey if one else to know print the anser plese say me..in the test #4 i have a empty string, but the judge say me "wa" in test #4.... why??? help me please.

#include <bits/stdc++.h>
using namespace std;

int main(){
    string cad,res;
             cin>>cad;
             res = "";
    int tam = cad.length();
    int i,j;
        i=0; j=1;

    int boolean[tam]={0};

    while(j<tam){
        if(cad[i]==cad[j]){
            boolean[i] = 1;
            boolean[j] = 1;

            if(i-1>=0){
                i-=1;
                j+=1;
            }else{
                i=j+1;
                j+=2;
            }
        }else{
            i=j;
            j+=1;
        }
    }

    for(int i=0;i<tam;i++){
         if(boolean[i]==0)
             res+=cad[i];
     }
     cout<<res;
    return 0;
}