Page 6 of 7
445 WA.pls anyone help this helpless.pls
Posted: Sun Feb 15, 2009 9:45 pm
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;
}
shorojini
New poster
Posts: 4
Joined: Sat Aug 16, 2008 8:14 am
Top
445:TLE !!! please help me.......
Posted: Sat May 16, 2009 2:30 pm
by scor_k
Code: Select all
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
int main()
{
long long n,i,j,x,len,sum,a,k,b;
char arr[1000],c;
while(1)
{
scanf("%s",arr);
len=strlen(arr);
sum=0;
x=0;
while(x!=len)
{
for(i=x;i<len;i++)
{
if(isdigit(arr[i]))
sum=sum*10+arr[i]-'0';
else
break;
}
for(j=i;j<len;j++)
{
if(isupper(arr[j]) || arr[j]=='*' || arr[j]=='b')
{
for(a=0;a<sum;a++)
{
if(arr[j]!='b')
printf("%c",arr[j]);
if(arr[j]=='b')
printf(" ");
}
}
else if(arr[j]=='!')
printf("\n");
else
break;
}
x=j;
sum=0;
}
printf("\n");
}
return 0;
}
Re: 445 WA
Posted: Fri Sep 10, 2010 12:21 pm
by mehrab
i'm getting WA for 445 .
can anyone help me.
Code: Select all
#include <stdio.h>
int main()
{
char string[100000],number=0,i=0,j=0;
while(gets(string))
{
if(string[0]=='\0')
{
continue;
}
number=0;
for(i=0;string[i]!='\0';i++)
{
if(string[i]>='0' && string[i]<='9')
number+=(string[i]-48);
else if((string[i]>='A' && string[i]<='Z') || string[i]=='b' || string[i]=='*' || string[i]=='!' || (string[i]>='a'&& string[i]<='z'))
{
if(string[i]=='b')
string[i]=' ';
for(j=0;j<number;j++)
{
if(string[i]=='!')
printf("\n");
else
printf("%c",string[i]);
}
number=0;
}
}
printf("\n");
}
return 0;
}
WA: 445 - Marvelous Mazes
Posted: Thu Nov 04, 2010 10:00 pm
by faiem
#include<stdio.h>
int main()
{
char ch;long I,sum=0,n=0;
while((ch=getchar())!=EOF)
{
if(ch>=48&&ch<=57)
{sum=sum+ch-48;n=1;
}
else
{
if(ch=='b')
{for(I=1;I<=sum;I++)
printf(" ");
}
else if(ch=='!')
{ printf("\n");
}
else if(ch!='\n')
{
for(I=1;I<=sum;I++)
printf("%c",ch);
}
sum=0;
}
if(n==1&&ch=='\n')
{
printf("\n");
n=0;sum=0;
}
}
return 0;
}
//why WA...PLz help.
Re: 445 - Marvelous Mazes
Posted: Sun Feb 05, 2012 3:29 pm
by varagrawal
@linux: Should your output say "I PWN NOOBS"? Coz the sample output you have given is ignoring the blank space in the 3rd line of the 3rd test case.
445 Marvelous mazes WA
Posted: Tue May 01, 2012 6:13 pm
by mathgirl
I have tried with previous inputs, and the outputs match. But still getting WA. Can anyone who got AC pls help me out ?
Re: 445 Marvelous mazes WA
Posted: Wed May 02, 2012 12:38 am
by brianfry713
Descriptions for different mazes should be separated by a blank line in the output.
Re: 445 Marvelous mazes WA
Posted: Thu May 10, 2012 10:23 am
by mathgirl
Thanks I got AC. The newline was the issue.
445 Marvelous Mazes
Posted: Fri Sep 07, 2012 8:53 pm
by Sabiha_Fancy
Each time i submit the solution of this problem i am getting runtime error. If anyone would help me to find my error i will be glad.
here is my code
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char row[135];
int sum,flag,len,i,j;
flag = 0;
while(gets(row))
{
len = strlen(row);
sum=0;
if(len>0)
{
for(i=0; i<len; ++i)
{
if(row
== '!')
{
printf("\n");
flag++;
}
else if(row == '\0')
{
if(row[i-1] == '!')
{
printf("\n");
break;
}
else
{
break;
}
}
else if(row>='0' && row<='9')
sum = sum+(row-'0');
else if(row == 'b')
{
for(j=1; j<=sum; ++j)
printf(" ");
sum = 0;
}
else if(row>='A' && row<='Z')
{
for(j=1; j<=sum; ++j)
printf("%c",row);
sum = 0;
}
else if(row == '*')
{
for(j=1; j<=sum; ++j)
printf("*");
sum = 0;
}
}
printf("\n");
}
}
return 0;
}
Re: 445 Marvelous Mazes
Posted: Mon Sep 10, 2012 10:58 pm
by brianfry713
Increase the size of your row array and you'll get WA instead of RE. Put your code inside the code blocks.
445 - Marvelous Mazes - Wrong answer
Posted: Thu Nov 08, 2012 6:42 pm
by stadoblech
im having wrong answer here
Code: Select all
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String line;
Scanner scan = new Scanner(System.in);
while(scan.hasNextLine()) {
line = scan.nextLine();
createMaze(line);
}
}
public static void createMaze(String code) {
int tempNumberOfBlocks = 0;
int numberOfBlocks = 0;
String result = "";
for(int i = 0; i < code.length();i++) {
if(Character.isDigit(code.charAt(i))) {
numberOfBlocks = tempNumberOfBlocks + (int)(code.charAt(i)-48);
tempNumberOfBlocks = (int)(code.charAt(i)-48);
//System.out.println(numberOfBlocks);
} else if (Character.isLetter(code.charAt(i))) {
tempNumberOfBlocks = 0;
if((code.charAt(i))=='b') {
for(int k = 0;k < numberOfBlocks;k++) {
result += " ";
}
} else {
for(int k = 0;k < numberOfBlocks;k++) {
result += code.charAt(i);
}
}
} else if (code.charAt(i)== '!') {
result += "\n";
tempNumberOfBlocks = 0;
} else if (code.charAt(i) == '*') {
result += "*";
tempNumberOfBlocks = 0;
}
}
System.out.println(result);
}
}
works great on my pc
anyone could help ?
p.s. begginer in java
Re: 445 - Marvelous Mazes - Wrong answer
Posted: Fri Nov 09, 2012 12:52 am
by brianfry713
Try input 123T, output should be TTTTTT
Re: 445 - Marvelous Mazes - Wrong answer
Posted: Fri Nov 09, 2012 2:19 pm
by stadoblech
brianfry713 wrote:Try input 123T, output should be TTTTTT
i tried and works fine... really dont know whats wrong ...
Re: 445 - Marvelous Mazes - Wrong answer
Posted: Fri Nov 09, 2012 8:55 pm
by brianfry713
You're only printing 5 T's, there should be 6 T's.
https://ideone.com/X2DXd1
Re: 445 - Marvelous Mazes - Wrong answer
Posted: Thu Aug 08, 2013 1:21 pm
by f.maru
i need some help what is wrong with this code?
Code: Select all
#include<iostream>
#include<string>
using namespace std;
void draw(int n,char t)
{
if (t!='!')
for(int i=1;i<=n;i++)
cout<<t;
else
cout<<endl;
}
void drw (string a)
{
if (a!="")
{
int w=0;
while(w<=a.length())
{
if (a[w]=='!')
draw(1,'!');
if (int(a[w])>48 && int(a[w])<58)
{
int q=0;
while(a[w]>48 && int(a[w])<58)
{
q+=int(a[w])-48;
w++;
}
if (a[w]=='b')
draw(q,' ');
else
draw(q,a[w]);
}
w++;
}
cout<<endl;
}
}
int main()
{
string b,c;
b.clear();
c.clear();
while(getline(cin,c))
{
// if(b!="")
// c=c+'!'+b;
// else
// {
drw(c);
c.clear();
// }
}
}