test case issue

Revision en2, by 1_coder, 2016-09-24 21:11:09

this is the contest http://mirror.codeforces.com/contest/719 question no 2 can anyone ell me why i m failing 5th test case because i cant see that due to its large input plz help me guys thnxx....

include

using namespace std;

int main() { char a[100000],temp; int n,c=0; cin>>n; for(int i=0;i<n;i++){ cin>>a[i];

} for(int i=1;i<n-1;i++){ if(a[i-1]==a[i]){ if(a[i+1]!=a[i]){ if(i+1<n){ temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; c++; } else{ if(a[i-1]=='r'){ a[i]='b'; c++;

}
        else{
            c++;
            a[i]='r';
        }
        }
    }
    else{
        if(a[i-1]=='r'){
            a[i]='b';
        c++;

        }
        else{
            c++;
            a[i]='r';
        }

    }
}

} cout<<c; return 0;

}

Tags #c++, all problems, #algorithms

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English 1_coder 2016-09-24 21:16:01 1 Tiny change: 'an anyone ell me why' -> 'an anyone tell me why'
en3 English 1_coder 2016-09-24 21:14:39 882
en2 English 1_coder 2016-09-24 21:11:09 882
en1 English 1_coder 2016-09-24 21:08:56 206 Initial revision (published)