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

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

11541 - Decoding

Post by zuna » Wed Jan 21, 2009 4:53 pm

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.

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

Re: 11541 Decoding

Post by sohel » Thu Jan 22, 2009 7:43 am

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

Post by asupal » Sun Feb 01, 2009 8:44 pm

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

Post by aia » Sun Mar 07, 2010 3:28 pm

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

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

Re: 11541 - Decoding WA Please help me

Post by Mizanur Rahman(IUK) » Wed Dec 08, 2010 6:08 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.............

Post by graph_dp » Mon Oct 01, 2012 10:24 pm

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

Post by brianfry713 » Tue Oct 02, 2012 9:15 pm

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

Post by sith » Tue Dec 04, 2012 7:47 am

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

Post by brianfry713 » Sat Dec 08, 2012 8:06 am

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

Post by sith » Sun Dec 09, 2012 5:14 am

thank you,
silly typo
got AC

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

Re: 11541 - Decoding

Post by iftenet » Mon Dec 23, 2013 12:11 pm

#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

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

Re: 11541 - Decoding

Post by brianfry713 » Wed Jan 15, 2014 12:26 am

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

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

Re: 11541 - Decoding

Post by uDebug » Sun Mar 16, 2014 9:36 am

Replying to follow the thread.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

Post Reply

Return to “Volume 115 (11500-11599)”