got AC
11220 - Decoding the message.
Moderator: Board moderators
-
- New poster
- Posts: 19
- Joined: Fri Sep 05, 2008 6:39 pm
- Location: bangladesh
- Contact:
why tle????pls help me
Last edited by tajbir2000 on Sat Aug 15, 2009 10:49 pm, edited 1 time in total.
Re: 11220 - Decoding the message
To tajbir2000
You can never avoid TLE with this. You had to red input character by character and process them.
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.
You can never avoid TLE with this. You had to red input character by character and process them.

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.
This may be the address of success.
-
- Learning poster
- Posts: 84
- Joined: Fri Jan 09, 2009 4:37 pm
- Location: IRAN
Re: 11220 - Decoding the message
for output :
You must print a blank line between each test case.
You must print a blank line between each test case.
Impossible says I`m possible
Re: 11220 - Decoding the message
I edited. But why this is TLE?????? 

try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 11220 - Decoding the message
Is there any wrong in taking input???
Why i got TLE?
Some 1 plz help me.
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.
This may be the address of success.
Re: 11220 - Decoding the message
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);
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);
-
- New poster
- Posts: 50
- Joined: Tue May 25, 2010 9:10 am
- Contact:
Re: 11220 - Decoding the message (Why WA)
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 ..... 

-
- New poster
- Posts: 19
- Joined: Thu May 20, 2010 8:58 am
Re: 11220 - Decoding the message
dont print a new line after the last output...gave me a lot of pain 

one day...
Re: 11220 - Decoding the message
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;
}
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;
}
Re: 11220 - Decoding the message
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 .....
Re: 11220 - Decoding the message
@xtranger991 look this input and try it in your code, then you may be find why your code give the wrong answer
Sample input:
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 .....
-
- New poster
- Posts: 21
- Joined: Mon Apr 08, 2013 8:38 am
Re: 11220 - Decoding the message
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11220 - Decoding the message
You must print a blank line between each test case.
Don't print an extra blank line at the end.
Don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 21
- Joined: Mon Apr 08, 2013 8:38 am
Re: 11220 - Decoding the message
Thank you. AC
Re: 11220 - Decoding the message
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;
}