Page 4 of 7
Posted: Tue Nov 22, 2005 10:06 pm
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...
Posted: Wed Nov 23, 2005 1:07 pm
by Roby
Thanx a lot Trust Noone
Now, I got clear AC with 0 seconds... Yuppy!!!
p - 445 I don't know why it is wrong
Posted: Sun Feb 05, 2006 2:23 pm
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;
}
445 WA
Posted: Fri Feb 24, 2006 2:12 pm
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;
}
445 PE
Posted: Wed Mar 08, 2006 3:30 pm
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;
}
Posted: Sun Mar 12, 2006 3:17 pm
by Artikali
445...WA
Posted: Fri Aug 25, 2006 9:32 am
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...

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
445 Output limit exceeded...Plz help!!!!!
Posted: Tue Dec 12, 2006 3:11 pm
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;
}
Posted: Tue Dec 19, 2006 5:08 am
by razor_red
I've tried your code, when I enter sample input your program run into
an infinite loop.
Posted: Wed Mar 21, 2007 2:07 pm
by newton
yes i got the point and AC!
thanx everyvody.
Posted: Wed Mar 21, 2007 4:06 pm
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;
}
Posted: Sun Apr 29, 2007 4:43 am
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.
WA in 445
Posted: Sun May 06, 2007 7:47 am
by Neli
I think I've checked all the conditions.
But couldn't find any problem.plz help me.
Posted: Sun May 06, 2007 8:16 am
by sohel
There are several other threads related to this problem.
Please don't create a new thread if one already exists.
Posted: Tue Jun 26, 2007 1:40 pm
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