11220 - Decoding the message.

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

Moderator: Board moderators

tajbir2000
New poster
Posts: 19
Joined: Fri Sep 05, 2008 6:39 pm
Location: bangladesh
Contact:

why tle????pls help me

Post by tajbir2000 » Tue Jan 06, 2009 11:04 am

got AC
Last edited by tajbir2000 on Sat Aug 15, 2009 10:49 pm, edited 1 time in total.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11220 - Decoding the message

Post by Obaida » Sat Jan 17, 2009 12:10 pm

To tajbir2000
You can never avoid TLE with this. You had to red input character by character and process them. :D

Why my one got TLE. I was getting wa in .04scc but when i was trying to change my output style. It got TLE.
Some one please check this. :(

Code: Select all

removed
Last edited by Obaida on Wed Apr 15, 2009 10:01 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

User avatar
vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

Re: 11220 - Decoding the message

Post by vahid sanei » Sun Jan 18, 2009 1:46 pm

for output :
You must print a blank line between each test case.
Impossible says I`m possible

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11220 - Decoding the message

Post by Obaida » Mon Jan 19, 2009 7:32 am

I edited. But why this is TLE?????? :-?
try_try_try_try_&&&_try@try.com
This may be the address of success.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11220 - Decoding the message

Post by Obaida » Sat Apr 18, 2009 8:25 am

Is there any wrong in taking input???
Why i got TLE? :-?
Some 1 plz help me.

Code: Select all

#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
	int n,count=0,c,t_c,i,ca=0;
	bool print=0;
	char st[31];
	scanf("%d%*c",&n);
	scanf("%*c");
	while(1)
	{
		printf("Case #%d:\n",++ca);
		while(1)
		{
			gets(st);
			if(st[0]=='\0'){count++;break;}
			c=0;t_c=0;print=0;
			for(i=0;st[i];i++)
			{
				if(isspace(st[i]))
				{
					if(print){c++;print=0;}
					t_c=0;
				}
				else
				{
					if(t_c==c){printf("%c",st[i]);print=1;}
					t_c++;
				}
			}
			puts("");
		}
		if(count==n)break;
		puts("");
	}
	return 0;
}
try_try_try_try_&&&_try@try.com
This may be the address of success.

MRH
Learning poster
Posts: 51
Joined: Mon Aug 11, 2008 9:09 pm

Re: 11220 - Decoding the message

Post by MRH » Tue Apr 21, 2009 4:15 pm

hello " Obaida "
just add memset(st, 0, sizeof(st)); after puts("");
and netx time when u get this tyep problem then u use all of cin>> and cot<< .
OR use gets(str); for tast case then sscanf(str,"%d",&cas);

User avatar
shaon_cse_cu08
New poster
Posts: 50
Joined: Tue May 25, 2010 9:10 am
Contact:

Re: 11220 - Decoding the message (Why WA)

Post by shaon_cse_cu08 » Tue Sep 07, 2010 3:03 pm

Hello... with great afford's and after reading all the tread's.. I still can't figure out the BUG in my code.... I can realize I m printing extra newline or not printing 1 where it is need... But I cant find .... Plzzzz some 1 Help me... Here is my code... :( :(

Code: Select all

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

int main()
{
	int i,j,k,l,m,cas,t,tag,flag,len;

	char a[100][2000],bfr,b[100][500];

	scanf("%d",&t);

	printf("\n");

	scanf("%c",&bfr);

	for(cas=1;cas<=t;cas++)
	{

		for(i=0;;i++)
		{
			gets(a[i]);

			if(a[i][0]=='\0')
				break;
		}
		
		printf("Case #%d:\n",cas);

		for(j=0;j<i;j++)
		{
			l=0;
		    tag=1;
			flag=1;

			len=strlen(a[j]);
			for(k=0;k<len;k++)
			{
				if(tag&&a[j][k]!=' ')
					for(m=k+1;m<=k+l;m++)
						if(a[j][m]==' ')
						{
							flag=0;
							break;
						}

				if((m==k+l+1)&&flag&&m<len)
				{
					b[j][l]=a[j][k+l];

					tag=0;
					flag=0;
					l++;
				}
				if(a[j][k]==' ')
				{
					tag=1;
					flag=1;
				}
			}
			b[j][l]='\0';
			
			
			puts(b[j]);


		}
		if(cas<t)
			printf("\n");

	}
return 0;
}
I'll keep holding on...Until the walls come tumbling down...And freedom is all around ..... :x

kissu parina
New poster
Posts: 19
Joined: Thu May 20, 2010 8:58 am

Re: 11220 - Decoding the message

Post by kissu parina » Sat Feb 05, 2011 8:53 pm

dont print a new line after the last output...gave me a lot of pain :x
one day...

masum_cse
New poster
Posts: 1
Joined: Tue Nov 08, 2011 5:10 pm

Re: 11220 - Decoding the message

Post by masum_cse » Wed Nov 09, 2011 12:40 pm

This is my code .I could'nt find out any reason ,why my code is getting WA....
Help ...me ..please>>>>>

#include<stdio.h>
#include<string.h>
int main()
{

int i,j,k,l,m,n;
char c[100000],ch;

scanf("%d",&n);
scanf("%c",&ch);
scanf("%c",&ch);
printf("Case #1:\n");

for(i=1;i<=n;i++)
{
k=0;
j=0;
m=0;

while(1)
{
scanf("%c",&ch);

if((ch>=65&&ch<=90)||(ch>=97&&ch<=122))
{
c[j++]=ch;
m=0;
}

else if(ch==' ')
{
if(k<j)
{
printf("%c",c[k]);
k++;
}
j=0;
m=0;
memset(c,'\0',sizeof(c));
}

else if(ch=='\n')
{
m++;
if(k<j)
{
printf("%c\n",c[k]);
k=0;
j=0;
memset(c,'\0',sizeof(c));
}
else if(m==2)
{
if(i==n)
break;
printf("Case #%d:\n",i+1);
m=0;
memset(c,'\0',sizeof(c));
break;
}

else
{
printf("\n");
j=0;
k=0;
memset(c,'\0',sizeof(c));
}
}

}

}
return 0;
}

shuvokr
Learning poster
Posts: 66
Joined: Tue Oct 02, 2012 8:16 pm
Location: Bangladesh

Re: 11220 - Decoding the message

Post by shuvokr » Mon Oct 07, 2013 11:25 pm

xtranger991 try it

Code: Select all

scan test case
enter
enter
scan input and print output ( input is terminated when input is only a new line )
scan input and print output ( input is terminated when input is only a new line )
.......
.......

Code: Select all

enjoying life ..... 

shuvokr
Learning poster
Posts: 66
Joined: Tue Oct 02, 2012 8:16 pm
Location: Bangladesh

Re: 11220 - Decoding the message

Post by shuvokr » Tue Oct 08, 2013 12:27 am

@xtranger991 look this input and try it in your code, then you may be find why your code give the wrong answer
Sample input:

Code: Select all

2

Hey good lawyer
as I previously previewed
yam does a soup(and 4 space)    

Code: Select all

enjoying life ..... 

Angry Bird
New poster
Posts: 21
Joined: Mon Apr 08, 2013 8:38 am

Re: 11220 - Decoding the message

Post by Angry Bird » Fri Nov 22, 2013 6:48 pm

Getting WA for many times.... But why?

Code: Select all

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <sstream>

using namespace std;

int counter;

void fn(string s)
{
    int l=s.size();

    if(l>=counter+1)
    {
        cout<<s[counter];
        counter++;
    }
}

int main()
{
    string s,smain;
    char ch;
    int t;
    cin>>t;
    getchar();
    for(int i=1; i<=t; i++)
    {
        vector<string>ss;
        scanf("\n");
        scanf("\n");
        while(getline(cin,smain))
        {
            if(smain=="")
            {
                break;
            }

            ss.push_back(smain);
        }

        cout<<"Case #"<<i<<":"<<endl;

        for(int j=0; j<ss.size(); j++)
        {
            counter=0;
            s=ss[j];
            vector<string>stor;
            istringstream iss(s);

            do
            {
                string sub;
                iss >> sub;
                stor.push_back(sub);
            }
            while (iss);

            for(int k=0; k<stor.size(); k++)
            {
                fn(stor[k]);
            }
            cout<<endl;
        }
        cout<<endl;
    }

    return 0;
}


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

Re: 11220 - Decoding the message

Post by brianfry713 » Fri Nov 22, 2013 9:53 pm

You must print a blank line between each test case.

Don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!

Angry Bird
New poster
Posts: 21
Joined: Mon Apr 08, 2013 8:38 am

Re: 11220 - Decoding the message

Post by Angry Bird » Fri Nov 22, 2013 10:58 pm

Thank you. AC

Shihab
New poster
Posts: 33
Joined: Thu Jun 13, 2013 1:19 pm

Re: 11220 - Decoding the message

Post by Shihab » Tue Jan 07, 2014 1:17 pm

WA help

Code: Select all

#include<stdio.h>
#include<string.h>
int main()
{
    int i=1,j,n,words,test_case,length,letters,characters;
    char text[110][40];
    FILE *fp,*op;
    //fp=fopen("Input.txt","r");
    //fscanf(fp,"%d",&test_case);
    scanf("%d",&test_case);
    while(i<=test_case)
    {
        j=0;
        printf("Case #%d:\n",i);
        while(gets(text[j]))
        {
            length=strlen(text[j]);
            if(length==0 && j>1)
                break;
            letters=words=1;
            characters=0;

            while(text[j][characters]!='\0')
            {
                if(text[j][characters]!=' ')//checking for words
                {
                    if(letters==1)
                        words++;

                    letters++;//counting letters in a word

                    if(letters==words)
                    {
                        printf("%c",text[j][characters]);
                    }
                }
                else
                {
                    if(letters<words && letters>1)
                        words--;

                    letters=1;
                }
                characters++;
            }
            j++;
            printf("\n");
        }
        //fclose(fp);
        i++;
    }
    return 0;
}


Post Reply

Return to “Volume 112 (11200-11299)”