Page 1 of 4

11946- Code Number

Posted: Sat Apr 09, 2011 8:54 am
by naseef_07cuet
I am getting wrong answer... What is th tricky case?

Re: 11946- Code Number

Posted: Sat Apr 09, 2011 9:27 pm
by iriz7482
I also got W.A many times because I forgot to add \n in the line

Code: Select all

scanf("%d\n",&n);
n is number of test cases.
Also remember not to print a blank line in the last test case.
Hope this help :D

Re: 11946- Code Number

Posted: Sun Apr 10, 2011 4:03 pm
by naseef_07cuet
Still WA.... here is my code...

Code: Select all

// Code Removed after AC.. :D

11946- Code Number

Posted: Tue Apr 19, 2011 4:28 pm
by rafay-hasan
I am getting TLE for this problem. can anyone tell me whats wrong with my code.


#include<stdio.h>
#include<string.h>
char a[91];
int c,i,j,found,got,t,test,line;

int main()
{
scanf("%d",&test);
getchar();
for(t=1;t<=test;t++)
{
while(1)
{
gets(a);
c=strlen(a);
if(c==0)
break;
found=got=0;
found=check();
for(i=0;i<c;i++)
{
if(a=='1')
a='I';
else if(a=='2')
a='Z';
else if(a=='3')
a='E';
else if(a=='4')
a='A';
else if(a=='5')
a='S';
else if(a[i]=='6')
a[i]='G';
else if(a[i]=='7')
a[i]='T';
else if(a[i]=='8')
a[i]='B';
else if(a[i]=='9')
a[i]='P';
else if(a[i]=='0')
a[i]='O';
printf("%c",a[i]);
}
printf("\n");
}
printf("\n");
}
return 0;
}

Re: 11946- Code Number

Posted: Tue Apr 26, 2011 8:52 pm
by robot
Hi rafai
u arise some problem....
1. please while(1) change--->while(gets(a))
2.problem says print a blank line between test case not at all so be careful and edit ur blank line
3.garbage variable or function be delete.......

ASU(SUST) :)

Re: 11946- Code Number

Posted: Thu May 12, 2011 6:07 pm
by Larry
The problem description's encode/decode message for this problem is wrong -- use the sample input/output. It uses some 2s as Z's or something.

Re: 11946- Code Number

Posted: Sat Jun 18, 2011 8:56 am
by shaon_cse_cu08
Hai i m confused with the blank line instance... I have tried every possible way But it failed...Plz this is my code...Some1 who have AC plzz help me....This one is making me creazy..... :( :(

Code: Select all

Deleted After AC....Insted of considering line by line..i was considering the whole case....

Re: 11946- Code Number

Posted: Wed Aug 10, 2011 7:32 am
by mostafa_angel
hi...
I got WA ! But I cant not figure it out...
Can Anybody help...

my code :

Code: Select all

AC... :)

11946- Code Number

Posted: Mon Dec 19, 2011 5:23 pm
by snape
i got WA && also dont under stand input system,plz help
my code is here:
#include<stdio.h>

char a[100];
int c,i,j,found,got,t,test,line,w=0;

int main()
{
scanf("%d",&test);
getchar();
while(test--)
{

while(gets(a) && (a[0]!='\n'))
{


if(c==0)
break;

for(i=0;a!='\0';i++)
{
if(a=='1')
a='I';
else if(a=='2')
a='Z';
else if(a=='3')
a='E';
else if(a=='4')
a='A';
else if(a=='5')
a[i]='S';
else if(a[i]=='6')
a[i]='G';
else if(a[i]=='7')
a[i]='T';
else if(a[i]=='8')
a[i]='B';
else if(a[i]=='9')
a[i]='P';
else if(a[i]=='0')
a[i]='O';
else
{}
}
printf("%s\n",a);
}

}
return 0;
}

11946- Code Number WA why?

Posted: Wed Jan 04, 2012 12:57 pm
by uvasarker
I am also WA. I do not know why? Please, give some critical test cases, please. Please.....
Here is my code.

Code: Select all

#include <cstdio>
#include <cstring>
#include <cctype>

int main()
{
		int T,t,f=0;
		//freopen("in-11946.txt","r",stdin);
		//freopen("11946.txt","w",stdout);
		scanf("%d\n",&T);
		
		for(t=1 ; t<=T ; t++)
		{
				char ch[500]={'\0'};
				while(gets(ch))
				{
					int len=strlen(ch);
					if(f==1 || ch[0]=='\0' || ch[0]=='\n')
					{printf("\n\n"); f=0;}
				for(int i=0 ; i<len ; i++)
					{
							if(((ch[i]!=' ' || ch[i]=='.') && ch[i+1]=='\0'))
							{
									f=1;
							}
		
				
						if(isdigit(ch[i]))
						{
								if(ch[i]=='0')
									printf("O");
								else if(ch[i]=='1')
									printf("I");
								else if(ch[i]=='2')
									printf("Z");
								else if(ch[i]=='3')
									printf("E");
								else if(ch[i]=='4')
									printf("A");
								else if(ch[i]=='5')
									printf("S");
								else if(ch[i]=='6')
									printf("G");
								else if(ch[i]=='7')
									printf("T");
								else if(ch[i]=='8')
									printf("B");
								else if(ch[i]=='9')
									printf("P");
						}
						else
							printf("%c",ch[i]);
						
					}
					
				}
		}
}



Re: 11946- Code Number

Posted: Sat Jan 14, 2012 1:52 am
by brianfry713
Your output doesn't match the sample output, it should have the same newlines.

Re: 11946- Code Number

Posted: Sat Jan 14, 2012 1:55 am
by brianfry713
snape, c is uninitialized so it equals 0. This statement causes your program to not print anything:
if(c==0)
break;

Re: 11946- Code Number

Posted: Sun Jan 15, 2012 5:21 pm
by uvasarker
Hi,
brianfry713
I want to thank you from my heart for your helping.
Actually, I can't spend time on uva problem or any online program because I am busy at Programming camp 2012 (BUET). You know I am new coder so I am learning programming. This camp period is 9:00 AM to 7:00 PM (almost whole day).
So, I will try your test cases and suggestion after this camp.
Thanks again from my heart.

Re: 11946- Code Number

Posted: Fri Feb 10, 2012 12:37 pm
by uvasarker
Thanks a lot.
Thanks a lot.
Thanks a lot boss.
Your suggestions are so helpful.
Finally, I got it AC.

11946 - Code Number

Posted: Tue Feb 14, 2012 3:35 pm
by alfar01
Why I got WA with my code?

Code: Select all

#include<stdio.h>
#include<string.h>
int main()
{
    freopen("11946.in","r",stdin);
	freopen("11946.out","w",stdout);
	int i,j,stat,part=1,flag1=1,flag2=1;
	char c[110][100],ans[]={"OIZEASGTBP"};
	scanf("%d\n",&stat);
	while(part<=stat){
		flag1?flag1=0:putchar('\n');
		for(i=0;;i++){gets(c[i]);if(c[i][0]=='\0')break;}
		for(i=0;c[i][0]!='\0';i++)
			for(j=0;c[i][j]!='\0';j++)
				if(c[i][j]>='0'&&c[i][j]<='9')
					c[i][j]=ans[c[i][j]-'0'];
		for(i=0;;i++){
			if(c[i][0]=='\0')break;
			flag2?flag2=0:putchar('\n');
			printf("%s",c[i]);
		}
		part++;
	}
	return 0;
}