11946 - Code Number

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

Moderator: Board moderators

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm
Location: CUET,Chittagong,Bangladesh

11946- Code Number

Post by naseef_07cuet » Sat Apr 09, 2011 8:54 am

I am getting wrong answer... What is th tricky case?
If you have determination, you can do anything you want....:)

iriz7482
New poster
Posts: 15
Joined: Mon Apr 04, 2011 3:18 pm

Re: 11946- Code Number

Post by iriz7482 » Sat Apr 09, 2011 9:27 pm

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

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm
Location: CUET,Chittagong,Bangladesh

Re: 11946- Code Number

Post by naseef_07cuet » Sun Apr 10, 2011 4:03 pm

Still WA.... here is my code...

Code: Select all

// Code Removed after AC.. :D
If you have determination, you can do anything you want....:)

rafay-hasan
New poster
Posts: 4
Joined: Sat Jul 03, 2010 1:04 pm

11946- Code Number

Post by rafay-hasan » Tue Apr 19, 2011 4:28 pm

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

robot
New poster
Posts: 29
Joined: Sun May 24, 2009 8:39 pm

Re: 11946- Code Number

Post by robot » Tue Apr 26, 2011 8:52 pm

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) :)

Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Re: 11946- Code Number

Post by Larry » Thu May 12, 2011 6:07 pm

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.

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

Re: 11946- Code Number

Post by shaon_cse_cu08 » Sat Jun 18, 2011 8:56 am

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....
I'll keep holding on...Until the walls come tumbling down...And freedom is all around ..... :x

mostafa_angel
New poster
Posts: 23
Joined: Sun Oct 04, 2009 12:03 pm

Re: 11946- Code Number

Post by mostafa_angel » Wed Aug 10, 2011 7:32 am

hi...
I got WA ! But I cant not figure it out...
Can Anybody help...

my code :

Code: Select all

AC... :)

snape
New poster
Posts: 5
Joined: Sat Dec 03, 2011 4:18 pm

11946- Code Number

Post by snape » Mon Dec 19, 2011 5:23 pm

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

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

11946- Code Number WA why?

Post by uvasarker » Wed Jan 04, 2012 12:57 pm

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



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

Re: 11946- Code Number

Post by brianfry713 » Sat Jan 14, 2012 1:52 am

Your output doesn't match the sample output, it should have the same newlines.
Check input and AC output for thousands of problems on uDebug!

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

Re: 11946- Code Number

Post by brianfry713 » Sat Jan 14, 2012 1:55 am

snape, c is uninitialized so it equals 0. This statement causes your program to not print anything:
if(c==0)
break;
Check input and AC output for thousands of problems on uDebug!

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 11946- Code Number

Post by uvasarker » Sun Jan 15, 2012 5:21 pm

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.

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 11946- Code Number

Post by uvasarker » Fri Feb 10, 2012 12:37 pm

Thanks a lot.
Thanks a lot.
Thanks a lot boss.
Your suggestions are so helpful.
Finally, I got it AC.

alfar01
New poster
Posts: 2
Joined: Tue Feb 14, 2012 3:27 pm
Location: Tainan,Taiwan

11946 - Code Number

Post by alfar01 » Tue Feb 14, 2012 3:35 pm

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

Post Reply

Return to “Volume 119 (11900-11999)”