Please read the new rule regarding the restriction on the use of AI tools. ×

AmoDraper's blog

By AmoDraper, history, 2 years ago, In English

Hi Codeforces Community! For the problem 'Decode String' I am getting a strange error, for the sample test case 8 i.e. :- 5 11111 I get am getting a wrong answer, mainly instead of 'aaaaa' I get 'aaaa:' this does not happen when you run this test case indivisually, but when taking all 9 test cases only this one is for some reason outputing wrong answer

Here's my code :-

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

int main() {
    int t;
    cin>>t;
    while (t--) {
        int n;
        cin>>n;
        string arr;
        cin>>arr;
        for(int i = 0 ; i < n ; i++){
            char temp = 48;
            int sum = arr[i];
            if((arr[i+2]) == '0' && (arr[i+3]) != '0') {
                sum = sum*10 + (arr[++i])+32;
                i++;
            }
            temp+=sum;
            cout<<temp;
        }
        cout<<endl;
    }
    return 0;
}

Your Help is Greatly Appreciated. :-)

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it