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

Trust Noone
New poster
Posts: 4
Joined: Wed Nov 16, 2005 8:54 pm

Post by Trust Noone »

The answer should 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

Good luck...

Roby
Experienced poster
Posts: 101
Joined: Wed May 04, 2005 4:33 pm
Location: Tangerang, Banten, Indonesia
Contact:

Post by Roby »

Thanx a lot Trust Noone
Now, I got clear AC with 0 seconds... Yuppy!!!

acmmamun
New poster
Posts: 5
Joined: Tue Jul 19, 2005 1:02 pm
Location: Bangladesh
Contact:

p - 445 I don't know why it is wrong

Post by acmmamun »

This is my Code:

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

char in[200];
char ch[200];
int flg,tmp1,tmp2,i,ff,len,aa;

int main(){

//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);

flg = 1;
ff = 0;
while(gets(ch)){

//ch = getc(stdin);
len = strlen(ch);
if(!len){
printf("\n");
continue;
}
i=0;
while(i<len){
if(ch=='!'||ch=='\n'){
printf("\n");
i++;
}
else if(ch>='0' && ch<='9'){
if(flg){
tmp1 = ch - '0';
flg = 0;
}
else{
tmp2 = tmp1 + (ch - '0');
flg = 1;
}
ff = 1;
i++;
}
else if(ff==1){
if(ch=='b')
ch = ' ';
if(!flg){
for(aa=1;aa<=tmp1;aa++)
printf("%c",ch);
flg = 1;
}
else{
for(aa=1;aa<=tmp2;aa++)
printf("%c",ch);
}
ff = 0;
i++;
}
else{
if(ch[i]=='b')
ch[i] = ' ';
printf("%c",ch[i]);
i++;
}
}
printf("\n");
/********/
}
printf("\n");
return 0;
}
There are nothing to say about me....

athlon19831
New poster
Posts: 20
Joined: Thu Jan 19, 2006 2:32 pm

445 WA

Post by athlon19831 »

Why i got WA?
#include <iostream>
using namespace std;
#include <cstring>
#include <cstdio>
#define N 10000
typedef struct
{
char c;
long num;
}Z;
int main(int argc, char* argv[])
{
char str[N];
long i,j,k,l,sum;
Z z;
z.num=0;
while(gets(str))
{
l=strlen(str);sum=0;
for(i=0;i<l;i++)
{
if(str>='0'&&str<='9')
{
sum=sum+long(str)-48;
}
else if(str>='A'&&str<='Z'||str=='a'||str>='c'&&str<='z')
{
z.num=sum;
z.c=str;
for(j=0;j<z.num;j++)
{
cout<<z.c;
}
sum=0;
}
else if(str=='b')
{
z.num=sum;
z.c=' ';
for(j=0;j<z.num;j++)
{
cout<<z.c;
}
sum=0;
}
else if(str[i]=='*')
{
z.num=sum;
z.c=str[i];
for(j=0;j<z.num;j++)
{
cout<<z.c;
}
sum=0;
}
else if(str[i]=='!')
{
cout<<endl;
sum=0;
}
if(i==l-1)
{
cout<<endl;
}
}
}
return 0;
}

xish
New poster
Posts: 5
Joined: Mon Feb 13, 2006 9:45 am

445 PE

Post by xish »

I don't know why... here is my code
#include <stdio.h>

int print(char character, int num)
{
int i;
for (i = 0 ; i < num ; i++)
{
printf("%c",character);
}
return 0;
}

int main()
{
char input;
char ouput;
int num;
bool lined;
num = 0;
lined = false;
while ((input = getchar()) != EOF)
{
if (((input == '!') || (input == '\n')) && (lined == false))
{
printf("\n");
lined = true;
continue;
}
lined = false;
if (input == 'b')
{
print(' ',num);
num = 0;
continue;
}
if ((input >= '0') && (input <= '9'))
{
num = num + input - '0';
continue;
}
else
{
print(input,num);
num = 0;
}
}
return 0;
}

Artikali
Learning poster
Posts: 68
Joined: Wed Sep 21, 2005 5:27 pm

Post by Artikali »


Iffat
New poster
Posts: 25
Joined: Sat Jul 22, 2006 9:47 am

445...WA

Post by Iffat »

A maze will consist of the alphabetic characters A-Z, * (asterisk), and spaces.
i think i don't understand the problem clearly...is the input should have only upper case letters , * , ! and b??

i have read the previous posts abt this problem.but i can't find my mistakes... :roll: :roll: :oops: but i m getting WA............. :(
my code gives currect output for the sample input..but i think my problem is in printing newline.
i printed a newline after each case and ofcourse for each '!'.
...and wat should be the array size?
anyone plzzz help me..... :( :(
thanx
mouri

ahah2002
New poster
Posts: 5
Joined: Mon Sep 18, 2006 4:09 pm

445 Output limit exceeded...Plz help!!!!!

Post by ahah2002 »

I got this strange error...output limit exceeded...Plz help me~~~

#include <iostream>
#include <string>
using namespace std;
int main(){
char ch;
string str;
int sum;
char letter;
bool b;
int i,j;

while (!cin.eof()){
b=true;
while (cin.get(ch)){
str+=ch;
if (ch=='\n' && b){
b=false;
}
else if(ch!='\n' && ch!=' ' && !b){
b=true;
}

else if (ch=='\n' && !b){
break;
}
}

for (i=0;i<str.length();i++){
if (str>='0' && str<='9'){
sum+=str-'0';
}

else if (str=='!' || str=='\n'){
cout<<endl;
}

else{
letter=str;
if (letter=='b'){
letter=' ';
}

for (j=0;j<sum;j++){
cout<<letter;
}

sum=0;

}
}
str.erase();

}

return 0;
}

razor_red
New poster
Posts: 2
Joined: Mon Nov 27, 2006 4:56 am
Location: Indonesia

Post by razor_red »

I've tried your code, when I enter sample input your program run into
an infinite loop.
Keep submitting to get AC !

newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton »

yes i got the point and AC!

Code: Select all

                     deleted



thanx everyvody.
Last edited by newton on Thu Mar 22, 2007 6:05 am, edited 2 times in total.

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio »

I didin't run your code, but maybe here ..

Code: Select all

         while(str[i]<'9' && str[i]>'0')
         {
            num += (int)str[i] - 48;
            i = i+1;
         }

andmej
Experienced poster
Posts: 158
Joined: Sun Feb 04, 2007 7:45 pm
Location: Medellin, Colombia

Post by andmej »

Trust Noone wrote:Try with this input:
1T1b5T!1T2b1T1b2T!1T1b1T2b2T!1T3b1T1b1T!3T3b1T!1T3b1T1b1T!5T1*1T!

11X21b1X!
4X1b1X!
My AC code outputs 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

By the way, here's a fancy test case:

Input:

Code: Select all

3X3b3X1b1X5b1X1b1X2b1X3b1X2b1X1b4X1b4X1b1X3b3X
1b1X4b1X1b1X1b1X2b1X2b1X1b2X1b1X3b2X1b1X1b1X2b1X1b1X2b1X1b3X2b1X
1b1X4b3X2b1X1b1X1b1X2b1X1b2X3b1X1b2X1b1X2b1X1b1X2b1X1b1X1b1X3b1X
3X3b1X5b1X1b1X3b1X2b1X3b1X2b1X1b4X1b4X1b3X1b3X


3O3b3O1b1O5b1O1b1O2b1O3b1O2b1O1b4O1b4O1b1O3b3O
1b1O4b1O1b1O1b1O2b1O2b1O1b2O1b1O3b2O1b1O1b1O2b1O1b1O2b1O1b3O2b1O
1b1O4b3O2b1O1b1O1b1O2b1O1b2O3b1O1b2O1b1O2b1O1b1O2b1O1b1O1b1O3b1O
3O3b1O5b1O1b1O3b1O2b1O3b1O2b1O1b4O1b4O1b3O1b3O
Output:

Code: Select all

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
It looks great with a fixed size font! Try it and you'll feel like pwning.

Neli
New poster
Posts: 7
Joined: Thu May 03, 2007 8:35 am
Location: Sylhet
Contact:

WA in 445

Post by Neli »

I think I've checked all the conditions.
But couldn't find any problem.plz help me.

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

Post by sohel »

There are several other threads related to this problem.
Please don't create a new thread if one already exists.

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

Post by Stanley Sentoso »

hi, i have same problem like u. i have try the sample and the result is correct, but when i submit my code, i got WA. this is my code :

Code: Select all

#include<stdio.h>

void print (char kar,int jum) {
	int j;
	if(kar=='b') kar=32;
	for (j=0;j<jum;j++) printf("%c",kar);
}

int main () {
	char i,data[133],karakter,l=0,k;
	int angka;
	while(gets(data)) {
		for (k=strlen(data);data[k-1]=='!';k--);
		angka=0;
		if (l)putchar('\n');
		l=1;i=0;
		while(i<k){
			if(data[i]>=48 && data[i]<=57) angka+=(data[i]-48);
			else if(data[i]=='!')putchar('\n');
			else {
				print(data[i],angka);
				angka=0;
			}
			i++;
		}
	}
	return 0;
}
there is something wrong with my code ? any suggestion ?
thx be 4..

goten

Post Reply

Return to “Volume 4 (400-499)”