Problems : RECIIDCD

I can see my code is working fine for small inputs. But on submission, CodeChef doesn’t accept it. Can anyone help?

Problems : RECIIDCD

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

void funct(string str){
for(int i=0 ; i< str.length() ;i++){
    if(str[i] >='1' && str[i] <='9'){
        for(int j=0; j<str[i]-'0' ; j++)
        {
            for(int k = i+1 ; ;k++ )
            {
                if(isalpha(str[k]))
                    cout<<str[k];
                else
                    break;
            }
        }
    }
}
}

int main()
{
int n;
cin>>n;
bool temp=true;
while(n){
    string str;
    cin>> str;
    if(temp){
        for(int i=0;;i++){
            if(isalpha(str[i])){
                continue;
            }else{
                temp= false;
                break;
            }
        }
    }
    funct(str);
    n--;
}
return 0;
}

For the sample testcase:

2
1A1B
2AB3C

your program gives output:

ABABABCCC

Thank you for clarifying my doubt. Few other competitive coding platforms accept the input formate as I gave here in my doubt. But CodeCheft accepts entire input at once and gives output in a single go.

1 Like