445 - Marvelous Mazes

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

Moderator: Board moderators

Stanley Sentoso
New poster
Posts: 2
Joined: Sat Jul 10, 2004 3:50 pm

Post by Stanley Sentoso »

oh, i miss something. i change my variabel data type from char to unsigned char, but i still got Presentation Error (PE). :(

rossi kamal
New poster
Posts: 14
Joined: Mon Sep 03, 2007 10:11 am
Contact:

445 wa and AC

Post by rossi kamal »

sorry i ve found that silly mistake.....but i want to mention that

my ac code gives the following result
make it clear plz..

input:
1T1b5T!1T2b1T1b2T!1T1b1T2b2T!1T3b1T1b1T!3T3b1T!1T3b1T1b1T!5T1*1T!

11X21b1X!
4X1b1X!


outout:
T TTTTT
T T TT
T T TT
T T T
TTT T
T T T
TTTTT*T


XX X

XXXX X

Fuad Hassan EWU
New poster
Posts: 38
Joined: Tue Jul 17, 2007 3:21 pm
Location: East West University

Post by Fuad Hassan EWU »

AC
Last edited by Fuad Hassan EWU on Sun Nov 25, 2007 9:02 pm, edited 1 time in total.
Eagle er moto daana meley urbo

sapnil
Experienced poster
Posts: 106
Joined: Thu Apr 26, 2007 2:40 pm
Location: CSE-SUST
Contact:

Post by sapnil »

To Fuad Hassan EWU

your output is like this:

Code: Select all

T TTTTT
T  T TT
T T  TT
T   T T
TTT   T
T   T T
TTTTT*T
 
XX   X
XXXX X<
but it must be

Code: Select all

T TTTTT
T  T TT
T T  TT
T   T T
TTT   T
T   T T
TTTTT*T
 
XX   X
XXXX X
<
'<' indecate cursor.

Hope its help

Thanks
Keep posting
Sapnil
"Dream Is The Key To Success"

@@@ Jony @@@

Fuad Hassan EWU
New poster
Posts: 38
Joined: Tue Jul 17, 2007 3:21 pm
Location: East West University

thanks

Post by Fuad Hassan EWU »

8) yes sapnil. it works. thanks... :wink:
Eagle er moto daana meley urbo

mahedee
New poster
Posts: 3
Joined: Sun Mar 23, 2008 1:29 pm
Contact:

445 - Marvelous Mazes #WA! Please help me.

Post by mahedee »

I tried this problem for several time but still getting WA. Could you please help me?

Code: Select all

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

int main()
{
	char str[500];
	int i,j,val=0;
	int len,flag =0;
	while(gets(str)!=NULL)
	{
		//printf("\n");
		len = strlen(str);
		if(len==0)
		{
			printf("\n");
			continue;
		}
		for(i = 0;i<len;i++)
		{
			if(str[i]>=48&&str[i]<=57)
			{
				val = val + (str[i]-48);
			}

			else
			{
				j = 0;
				do
				{
					if(str[i]=='b')
						printf(" ");
					else if(str[i] == '!'||str[i] == '\n')
						printf("\n");
					else
						printf("%c",str[i]);
					
					j++;
				}while(j<val);
				val = 0;
			}
		}
		printf("\n\n");		

	}
	return 0;
}
Mahedee

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

Re: 445 - Marvelous Mazes #WA! Please help me.

Post by sohel »

Do not create a new thread for a problem if one already exists!

aliahmed
New poster
Posts: 24
Joined: Fri Oct 24, 2008 8:37 pm
Location: CUET, Chittagong, Bangladesh
Contact:

445 - Marvelous Mazes

Post by aliahmed »

AC - Thanks
Last edited by aliahmed on Wed Jan 14, 2009 8:23 pm, edited 1 time in total.

abid_iut
Learning poster
Posts: 82
Joined: Wed Jul 16, 2008 7:34 am

Re: 445 WA

Post by abid_iut »

why I am getting WA
pls someone check
here is my code:

Code: Select all

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

int main()
{
	char str[200];
	int i,j,n,flag=0;
	while(gets(str)!=NULL){
		if(flag==0)flag=1;
		else putchar('\n');
		if(str[0]=='\n')
			printf("\n");
		else {
			n=0;
			for(i=0;str[i]!=0;i++)
				if(str[i]=='!')
					putchar('\n');
				else 
					if(str[i]>='1' && str[i]<='9')
						n+=str[i]-48;
					else {
						for(j=0;j<n;j++){
							if(str[i]=='b')printf(" ");
							else
							printf("%c",str[i]);
						}
						n=0;
					}
			}
		
	}
	return 0;
}
pls help :(
i love to wait... wait for better... and better will come...
http://akanoi.webs.com/

Articuno
Learning poster
Posts: 78
Joined: Sun Nov 30, 2008 5:00 pm
Location: IUT-OIC, Dhaka, Bangladesh

Re: 445 WA

Post by Articuno »

What are you trying to do with this? :

Code: Select all

if(str[0]=='\n')
         printf("\n");
You are using gets() and I think it is not possible for a string to have a '\n' character while you are using gets().
And for this case:

Code: Select all

101a
Your code fails.The output should be

Code: Select all

aa
I think this problem requires to read input character by character. Then you will be able to check for '\n' character.
There is one more thing. Think about this case:

Code: Select all

1a<There may be a '\n'>

if it is the last test case and there is a newline after "1a" your program will fail to print that newline. Do you get my point?
Wish you good luck. :-?
May be tomorrow is a better day............ :)

abid_iut
Learning poster
Posts: 82
Joined: Wed Jul 16, 2008 7:34 am

Re: 445 WA

Post by abid_iut »

Thanks Articuno
U r a great guide for me
Thanks for help :)
i love to wait... wait for better... and better will come...
http://akanoi.webs.com/

linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

Re: 445 - Marvelous Mazes

Post by linux »

Try these inputs

input:

Code: Select all

    1T1b5T!1T2b1T1b2T!1T1b1T2b2T!1T3b1T1b1T!3T3b1T!1T3b1T1b1T!5T1*1T!

    11X21b1X!
    4X1b1X!

    3X3b3X1b1X5b1X1b1X2b1X3b1X2b1X1b4X1b4X1b1X3b3X
    1b1X4b1X1b1X1b1X2b1X2b1X1b2X1b1X3b2X1b1X1b1X2b1X1b1X2b1X1b3X2b1X
    1b1X4b3X2b1X1b1X1b1X2b1X1b2X3b1X1b2X1b1X2b1X1b1X2b1X1b1X1b1X3b1X
    3X3b1X5b1X1b1X3b1X2b1X3b1X2b1X1b4X1b4X1b3X1b3X


    3O3b3O1b1O5b1O1b1O2b1O3b1O2b1O1b4O1b4O1b1O3b3O
    1b1O4b1O1b1O1b1O2b1O2b1O1b2O1b1O3b2O1b1O1b1O2b1O1b1O2b1O1b3O2b1O
    1b1O4b3O2b1O1b1O1b1O2b1O1b2O3b1O1b2O1b1O2b1O1b1O2b1O1b1O1b1O3b1O
    3O3b1O5b1O1b1O3b1O2b1O3b1O2b1O1b4O1b4O1b3O1b3O
output:

Code: Select all

    T TTTTT
    T  T TT
    T T  TT
    T   T T
    TTT   T
    T   T T
    TTTTT*T


    XX   X

    XXXX X


    XXX   XXX X     X X  X   X  X XXXX XXXX X   XXX
    X    X X X  X  X XX X   XX X X  X X  X XXX  X
    X    XXX  X X X  X XX   X XX X  X X  X X X   X
    XXX   X     X X   X  X   X  X XXXX XXXX XXX XXX


    OOO   OOO O     O O  O   O  O OOOO OOOO O   OOO
    O    O O O  O  O OO O   OO O O  O O  O OOO  O
    O    OOO  O O O  O OO   O OO O  O O  O O O   O
    OOO   O     O O   O  O   O  O OOOO OOOO OOO OOO
Solving for fun..

aliahmed
New poster
Posts: 24
Joined: Fri Oct 24, 2008 8:37 pm
Location: CUET, Chittagong, Bangladesh
Contact:

Re: 445 - Marvelous Mazes

Post by aliahmed »

I test your input
I think my output is correct
then why wa again?

linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

Re: 445 - Marvelous Mazes

Post by linux »

Code: Select all

if(str[i]=='\0')
break;
if(str[i]>=48 && str[i]<=56)
{
sum=sum+str[i]-48;
continue;
}
What about the digit 9? Why are ignoring it? It's not any less important to get AC. Other parts of the code seems okay.
Solving for fun..

shorojini
New poster
Posts: 8
Joined: Sat Aug 16, 2008 8:14 am

help help help.445

Post by shorojini »

i am getting wrong answer in this problem. :( :(
i am giving my code here.if there is not any prob in code then there must
be some prob in my input output system.please can anyone give me any solution and
some some sample input output.pls pls pls mark me my prob.pls pls pls. #include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
while(getline(cin,s))
{
int l=s.length();

int k=0;
for(int i=0;i<l;i++){

if(s>=48 && s<=57)
k=k+s-48;

else if(s=='!')
cout<<"\n";

else{
if(s=='b') {
for(int i=0;i<k;i++)
cout<<" "; }
else{
for(int j=0;j<k;j++)
cout<<s; }
k=0;
}

if(i==l-1)
cout<<"\n";

}




}
return 0;
}

Post Reply

Return to “Volume 4 (400-499)”