Page 1 of 1

11541 - Decoding

Posted: Wed Jan 21, 2009 4:53 pm
by zuna
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.

Re: 11541 Decoding

Posted: Thu Jan 22, 2009 7:43 am
by sohel
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.

Re: 11541 - Decoding

Posted: Sun Feb 01, 2009 8:44 pm
by asupal
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.

Re: 11541 - Decoding

Posted: Sun Mar 07, 2010 3:28 pm
by aia
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 ;
}
Thanks in advance

Re: 11541 - Decoding WA Please help me

Posted: Wed Dec 08, 2010 6:08 pm
by Mizanur Rahman(IUK)

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;
}

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

Posted: Mon Oct 01, 2012 10:24 pm
by graph_dp
thank you very much brianfry i got AC after removing getchar()

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

Posted: Tue Oct 02, 2012 9:15 pm
by brianfry713
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.

Re: 11541 - Decoding

Posted: Tue Dec 04, 2012 7:47 am
by sith
Hi,

I got WA

here is my solution

Code: Select all

AC

Re: 11541 - Decoding

Posted: Sat Dec 08, 2012 8:06 am
by brianfry713
don't print #

Re: 11541 - Decoding

Posted: Sun Dec 09, 2012 5:14 am
by sith
thank you,
silly typo
got AC

Re: 11541 - Decoding

Posted: Mon Dec 23, 2013 12:11 pm
by iftenet
#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;
}


I have faced WA. Please help

Re: 11541 - Decoding

Posted: Wed Jan 15, 2014 12:26 am
by brianfry713
Don't read from a file

Re: 11541 - Decoding

Posted: Sun Mar 16, 2014 9:36 am
by uDebug
Replying to follow the thread.