Блог пользователя AmoDraper

Автор AmoDraper, история, 2 года назад, По-английски

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. :-)

Полный текст и комментарии »

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится