## 11541 - Decoding

All about problems in Volume 115. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

zuna
New poster
Posts: 1
Joined: Wed Jan 21, 2009 4:44 pm

### 11541 - Decoding

Every inputted string will be valid. That is, every letter will be followed by 1 or more digits.
You may assume the decoded string won’t have a length greater than 200 and it will only consist of upper case alphabets.

Does it mean that it may have a test case with one alphabet and a number with 199 digits??
That's incredibly lage....
Can anyone who has got accepted tell me how many digits you assume for the test case??
Thanks very much.

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

### Re: 11541 Decoding

It says the decoded string won't have a length greater than 200.
That means the output string is at most 200 characters long since the output string is actually the decoded string.
The input given is the encoded string.

A case like A205 will not be given since it's decoded string length would exceed 200.
Hope it helps.

asupal
New poster
Posts: 1
Joined: Sun Feb 01, 2009 8:20 pm

### Re: 11541 - Decoding

very easy. u have declared 205 characters str. test case will not given 50. the input can be A-Z or 0-9 any characters.u cheeck ur problem input like
input
3 output
A0B0C1 C
A1B0C1D2 ACDD
the wrong format input will not given.

aia
New poster
Posts: 5
Joined: Wed Dec 02, 2009 12:01 am

### Re: 11541 - Decoding

hi
I hope sm could help me in this code
I don't know why it's WA

Code: Select all

``````#include<iostream>
#include<string>
#include <stdio.h>
#include <stdlib.h>
using namespace std ;
string Repeted(char ch , int rep)
{
string result ;
for(int i=0 ; i<rep ; i++)
result+=ch ;
return result ;
}
int convert_to_int (string n)
{
int s=0 ;
for(int i=0 ;i<n.length();i++)
{

s+=(n[i]-'0');
if(i<n.length()-1)
s*=10;
}
return s ;
}
int main()
{

int cases ;
cin>>cases ;
for(int j=0 ; j<cases ; j++)
{
string inPut , outPut="" ,strNum;
int numRep=0  , size=0;
char ch;
cin>>inPut ;
for(int i=0 ; i<inPut.length() ; i++)
{
if(inPut[i]>='A'&&inPut[i]<='Z')
{
ch=inPut[i] ;
continue ;
}
while(inPut[i]>='1'&&inPut[i]<='9')
{

strNum+=inPut[i] ;
size++ ;
if((inPut[i+1]>='1'&&inPut[i+1]<='9'))
i++ ;
else break;
}
numRep = convert_to_int(strNum) ;
outPut+=Repeted(ch , numRep)  ;
strNum="";
}
cout<<"Case "<<j+1<<":"<<outPut<<endl;
}
return 0 ;
}``````

Mizanur Rahman(IUK)
New poster
Posts: 12
Joined: Wed Aug 18, 2010 12:07 pm

Code: Select all

``````#include<iostream.h>
#include<stdio.h>
#include<string.h>

int main()
{
char a[2000];
int i,j,n[2000],t,k,count=0;
cin>>t;
for(k=1;k<=t;k++)
{count=0;
i=0;
scanf("%c",&a[i]);
cout<<"Case "<<k<<": ";
while(a[i]!='\n')
{
i++;
scanf("%d%c",&n[i-1],&a[i]);
if((int(a[i-1])>=65)&&(int(a[i-1])<=90))///////convetring upper case
{//a[i-1]=int (a[i-1])-32;
count=count+n[i-1];
//	if(count==200)
//		break;
//else

if(count>200)
n[i-1]=200+n[i-1]-count;
for(j=0;j<n[i-1];j++)
cout<<a[i-1];}
}
cout<<endl;
}
return 0;
}
``````

graph_dp
New poster
Posts: 7
Joined: Fri Sep 14, 2012 8:33 am

### uva=11541 i am gettign WA why.............

thank you very much brianfry i got AC after removing getchar()
Last edited by graph_dp on Sun Oct 07, 2012 11:58 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: uva=11541 i am gettign WA why.............

Doesn't match the sample I/O. Don't use a single getchar() and count on it being a newline, on some problems there may be different newline formats or trailing spaces.
Check input and AC output for thousands of problems on uDebug!

sith
Learning poster
Posts: 72
Joined: Sat May 19, 2012 7:46 pm

### Re: 11541 - Decoding

Hi,

I got WA

here is my solution

Code: Select all

``````AC
``````
Last edited by sith on Sun Dec 09, 2012 5:14 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11541 - Decoding

don't print #
Check input and AC output for thousands of problems on uDebug!

sith
Learning poster
Posts: 72
Joined: Sat May 19, 2012 7:46 pm

### Re: 11541 - Decoding

thank you,
silly typo
got AC

iftenet
New poster
Posts: 1
Joined: Mon Dec 23, 2013 12:09 pm

### Re: 11541 - Decoding

#include <stdio.h>
#include <string.h>
#define MAX 201
int main(){
static int T, t, i, j, k, K, f;
static char c,d, S[MAX], R[MAX];
freopen("in11541.txt", "r", stdin);
scanf("%d\n", &T);
for(t = 1; t <= T; t++){
scanf("%s", S);
for(i = 0, f = k = K = 0; (c = S) != '\0'; i++){
if(isalpha(c)){
if(f == 2){
for(j = 0; j < k; j++)
R[K++] = d;
k = 0;

}
f = 1;
d = c;
}else{
k = k*10+(c-48);
f = 2;
}
}
if(k > 0)
for(j = 0; j < k; j++)
R[K++] = d;
R[K] = '\0';
printf("Case %d: %s\n", t, R);
}
return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11541 - Decoding

Don't read from a file
Check input and AC output for thousands of problems on uDebug!

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm