Page 3 of 15
706 What's are the critical I/O
Posted: Sun Oct 26, 2003 7:28 am
by A Faltoo Fellow
Some body plz help me.
I see my propram ok. But the judge is replying as WA

.
I think I may have problem in choosing the horizontal & veritcal lines. Some one plz tell me its ASCII code.

( I took them as '-' (minus) and '|' (OR) ).
If I don't have any mistake in symbols. then tell me some critical I/O
706
Posted: Mon Oct 27, 2003 5:56 am
by A Faltoo Fellow
Posted: Sat Nov 15, 2003 2:20 pm
by Thozz
Hi!. I've dealed with ASCII code, blanks, zero size, eight digits numbers... but I always get WA. Does anyone know about the critical input??.
the output form??
Posted: Wed Nov 19, 2003 2:21 pm
by Jer
this is my output form :
3 1234567
*******aaa***aaa*********aaa***aaa***aaa
****b*****b*****b*b***b*b*****b*********b
****b*****b*****b*b***b*b*****b*********b
****b*****b*****b*b***b*b*****b*********b
*******aaa***aaa***aaa***aaa***aaa
****b*b*********b*****b*****b*b***b*****b
****b*b*********b*****b*****b*b***b*****b
****b*b*********b*****b*****b*b***b*****b
*******aaa***aaa*********aaa***aaa
I change "-"->"a","|"->"b"," "->"*" (and this's not point)
I want to know the the final " "(space)whether i have to cut it,
and put the text to new line..........
and the 706 prblem is also let me eat "WA" much time.........
Posted: Thu Nov 20, 2003 11:50 am
by Thozz
You should complete with blanks your lines till the end. I mean... all the lines must have the same width, and your fifth line:
*******aaa***aaa***aaa***aaa***aaa
is not completed:
*******aaa***aaa***aaa***aaa***aaa******
I still got WA!!!

706 WA
Posted: Wed Dec 10, 2003 12:14 pm
by gullutc
Why !!!?
[c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
static char map[10][5][4]={
{" - ",
"| |",
" ",
"| |",
" - "},
{" ",
" |",
" ",
" |",
" "},
{" - ",
" |",
" - ",
"| ",
" - "},
{" - ",
" |",
" - ",
" |",
" - "},
{" ",
"| |",
" - ",
" |",
" "},
{" - ",
"| ",
" - ",
" |",
" - "},
{" - ",
"| ",
" - ",
"| |",
" - "},
{"-- ",
" |",
" ",
" |",
" "},
{" - ",
"| |",
" - ",
"| |",
" - "},
{" - ",
"| |",
" - ",
" |",
" - "}
};
void do_display(int n, char *nb)
{
int i, j, k;
int l=strlen(nb);
for(i=0; i<l;i++)
{
putchar(map[( nb[i]-'0')][0][0]);
for(j=0; j<n; j++)
putchar(map[( nb[i]-'0')][0][1]);
putchar(map[( nb[i]-'0')][0][2]);
if(i!=l-1)
putchar(' ');
}
putchar('\n');
for(i=0; i<n; i++)
{
for(j=0; j<l; j++)
{
putchar(map[( nb[j]-'0')][1][0]);
for(k=0; k<n; k++)
putchar(map[( nb[j]-'0')][1][1]);
putchar(map[( nb[j]-'0')][1][2]);
if(j!=l-1)
putchar(' ');
}
putchar('\n');
}
for(i=0; i<l; i++)
{
putchar(map[( nb[i]-'0')][2][0]);
for(j=0; j<n; j++)
putchar(map[( nb[i]-'0')][2][1]);
putchar(map[( nb[i]-'0')][2][2]);
if(i!=l-1)
putchar(' ');
}
putchar('\n');
for(i=0; i<n; i++)
{
for(j=0; j<l; j++)
{
putchar(map[( nb[j]-'0')][3][0]);
for(k=0; k<n; k++)
putchar(map[( nb[j]-'0')][3][1]);
putchar(map[( nb[j]-'0')][3][2]);
if(j!=l-1)
putchar(' ');
}
putchar('\n');
}
for(i=0; i<l; i++)
{
putchar(map[( nb[i]-'0')][4][0]);
for(j=0; j<n; j++)
putchar(map[( nb[i]-'0')][4][1]);
putchar(map[( nb[i]-'0')][4][2]);
if(i!=l-1)
putchar(' ');
}
putchar('\n');
}
int main()
{
int s;
char nb[20];
while(2==fscanf(stdin, "%d %s", &s, nb))
{
if(!s)
break;
do_display(s, nb);
putchar('\n');
}
return EXIT_SUCCESS;
}
[/c]
Posted: Thu Jan 08, 2004 11:26 pm
by kiha
Er ... :/ maybe you could put some hints for this problem here , for example what to do if the size is 0 , or anything ... thanks in advance
Please!, please!!!.
Posted: Fri Jan 09, 2004 12:08 am
by Thozz
Hi!. I'm also looking for hints for this problem. I think my program gives a right answer. I've tried with 0 size... but still got WA
Thanks in advance!.

Posted: Sat Jan 10, 2004 1:12 pm
by kiha
Yupeeeeeeeeee
I got Accepted [P.E.] on this problem. I will try to get AC without P.E. , but I have some hints for you who get WA on this problem :
1) if you write in Pascal [I don't know how is it like in C/C++] and remember the number as a string , be careful if the last character of this string is a white space
2) remember to output one blank line after each test case
I know these are stupid hints already written in the Problem Statement, but in hurry you might have missed them.
If you follow my hints and still get WA, email me [
kiha@op.pl] and I can send you my code in Pascal. If so, please create a Subject of the message like 'Problem 706' or anything so that I won't delete your message as a rubbish.
Good luck to you solvers

Posted: Sat Jan 10, 2004 8:04 pm
by Thozz
Hi!. Thanks a lot for your hints!!. I will try and deal with the problem as soon as posible. Unfortunately, I'm now very busy

.
Thanks again!!

I try, try try and nothing
Posted: Mon Mar 01, 2004 11:54 pm
by wanderley2k
I try to submit and only answered is Accepted (P.E). I am test more line in end file and more blank spaces in end line and nothing.
I submit the code in programming-challenges.com and I recived: "Solved"
I don't know what can be?
Posted: Mon Mar 15, 2004 11:12 am
by soyoja
Dear, A Faltoo Fellow
Compare with before and after accepted problem, what is your difference points ?
I received all correct answer with my own test data.
But I don't understand why I got WA again and again... T_T
Plz help me.
I keep getting WA too:
Posted: Tue May 11, 2004 12:04 am
by regina
What is wrong with this code? -- I tried every possible input:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
class LCD
{
private:
char* disp[23];
int size;
public:
LCD()
{
for (int i = 0; i<23; i++)
{
disp
= NULL;
}
}
~LCD()
{
if (disp)
delete[] disp;
}
void AddNumber(int number)
{
int index = 0;
if (strcmp(disp[0], "") != 0) //this is the first row
{
BlankColumn();
}
switch (number)
{
//draw a zero
case 0:
index = DashMiddle(index);
index = LineBackAndFront(index);
index = BlankLine(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
break;
case 1:
index = BlankLine(index);
index = LineBack(index);
index = BlankLine(index);
index = LineBack(index);
index = BlankLine(index);
break;
case 2:
index = DashMiddle(index);
index = LineBack(index);
index = DashMiddle(index);
index = LineFront(index);
index = DashMiddle(index);
break;
case 3:
index = DashFront(index);
index = LineBack(index);
index = DashFront(index);
index = LineBack(index);
index = DashFront(index);
break;
case 4:
index = BlankLine(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
index = LineBack(index);
index = BlankLine(index);
break;
case 5:
index = DashMiddle(index);
index = LineFront(index);
index = DashMiddle(index);
index = LineBack(index);
index = DashMiddle(index);
break;
case 6:
index = DashMiddle(index);
index = LineFront(index);
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
break;
case 7:
index = DashMiddle(index);
index = LineBack(index);
index = BlankLine(index);
index = LineBack(index);
index = BlankLine(index);
break;
case 8:
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
break;
case 9:
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
index = LineBack(index);
index = DashMiddle(index);
break;
}
}
void SetSize(int s)
{
size = s;
int i;
for (i = 0; i<23; i++)
{
if (disp)
free (disp);
}
for (i = 0; i < 2*size + 3; i++)
{
disp = (char*)malloc( sizeof(char)*1000);
strcpy(disp, "");
}
for (i; i<23; i++)
{
disp = NULL;
}
}
void EndLine()
{
Print();
}
private:
void Print()
{
//end the strings:
for (int i = 0; i < size*2 + 3; i++)
{
strcat(disp, "\0");
printf("%s", disp);
printf("\n");
}
}
int BlankLine(int index)
{
for (int i = 0; i < size+2; i++)
{
strcat(disp[index], " ");
}
index++;
return index;
}
int LineBackAndFront(int index)
{
for (int i = 0; i < size; i++)
{
strcat(disp[index], "|");
for (int j = 0; j < size; j++)
{
strcat(disp[index], " ");
}
strcat(disp[index], "|");
index++;
}
return index;
}
void BlankColumn()
{
for (int i = 0; i < 2*size+3; i++)
{
strcat(disp, " ");
}
}
int LineBack(int index)
{
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size + 1; j++)
{
strcat(disp[index], " ");
}
strcat(disp[index], "|");
index++;
}
return index;
}
int LineFront(int index)
{
for (int i = 0; i < size; i++)
{
strcat(disp[index], "|");
for (int j = 0; j < size + 1; j++)
{
strcat(disp[index], " ");
}
index++;
}
return index;
}
int DashFront(int index)
{
int i;
for (i = 0; i < size; i++)
{
strcat(disp[index], "-");
}
for (i; i < size + 2; i++)
{
strcat(disp[index], " ");
}
index++;
return index;
}
int DashMiddle(int index)
{
strcat(disp[index], " ");
for (int i = 0; i < size; i++)
{
strcat(disp[index], "-");
}
strcat(disp[index], " ");
index++;
return index;
}
};
/*int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)*/
int main(int argc, char * argv)
{
char s = ' ';
int i;
int result;
LCD* myLCD = new LCD();
//get size
scanf( "%c", &s );
while (true)
{
while (s == ' ')
result = scanf( "%c", &s );
i = atoi(&s);
//check to see if it's not 10:
if (i == 1)
{
result = scanf( "%c", &s );
if (s != ' ')
{
i *=10;
i += atoi(&s);
}
}
else if (i == 0) //check for exit condition
{
result = scanf( "%c", &s );
while (s == ' ')
result = scanf( "%c", &s );
if (s == '0')
return 0;
}
if ( (i < 1) || (i > 10) )
{
printf("error: size must be between 1 and 10");
return 0;
}
myLCD->SetSize(i);
//get first char
result = scanf( "%c", &s );
while (s == ' ')
result = scanf( "%c", &s );
//get the rest of the string
int count=0;
while (s != '\n')
{
count++;
if ( (s < '0') || (s > '9'))
{
printf("error: non-numeric characters in line");
return 0;
}
myLCD->AddNumber(atoi(&s));
result = scanf( "%c", &s );
if (count > 
{
printf("error: number must be between 0 and 99 999 999");
return 0;
}
}
myLCD->EndLine();
//move the next line
result = scanf( "%c", &s );
}
return 0;
}
[cpp][/cpp]
Still Not accepted
Posted: Tue May 11, 2004 12:25 am
by regina
Hi -- can anyone tell me what's going on with my code?
Thanks...
[cpp]
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
class LCD
{
private:
char* disp[23];
int size;
public:
LCD()
{
for (int i = 0; i<23; i++)
{
disp
= NULL;
}
}
~LCD()
{
if (disp)
delete[] disp;
}
void AddNumber(int number)
{
int index = 0;
if (strcmp(disp[0], "") != 0) //this is the first row
{
BlankColumn();
}
switch (number)
{
//draw a zero
case 0:
index = DashMiddle(index);
index = LineBackAndFront(index);
index = BlankLine(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
break;
case 1:
index = BlankLine(index);
index = LineBack(index);
index = BlankLine(index);
index = LineBack(index);
index = BlankLine(index);
break;
case 2:
index = DashMiddle(index);
index = LineBack(index);
index = DashMiddle(index);
index = LineFront(index);
index = DashMiddle(index);
break;
case 3:
index = DashFront(index);
index = LineBack(index);
index = DashFront(index);
index = LineBack(index);
index = DashFront(index);
break;
case 4:
index = BlankLine(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
index = LineBack(index);
index = BlankLine(index);
break;
case 5:
index = DashMiddle(index);
index = LineFront(index);
index = DashMiddle(index);
index = LineBack(index);
index = DashMiddle(index);
break;
case 6:
index = DashMiddle(index);
index = LineFront(index);
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
break;
case 7:
index = DashMiddle(index);
index = LineBack(index);
index = BlankLine(index);
index = LineBack(index);
index = BlankLine(index);
break;
case 8:
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
break;
case 9:
index = DashMiddle(index);
index = LineBackAndFront(index);
index = DashMiddle(index);
index = LineBack(index);
index = DashMiddle(index);
break;
}
}
void SetSize(int s)
{
size = s;
int i;
for (i = 0; i<23; i++)
{
if (disp)
free (disp);
}
for (i = 0; i < 2*size + 3; i++)
{
disp = (char*)malloc( sizeof(char)*1000);
strcpy(disp, "");
}
for (i; i<23; i++)
{
disp = NULL;
}
}
void EndLine()
{
Print();
}
private:
void Print()
{
//end the strings:
for (int i = 0; i < size*2 + 3; i++)
{
strcat(disp, "\0");
printf("%s", disp);
printf("\n");
}
}
int BlankLine(int index)
{
for (int i = 0; i < size+2; i++)
{
strcat(disp[index], " ");
}
index++;
return index;
}
int LineBackAndFront(int index)
{
for (int i = 0; i < size; i++)
{
strcat(disp[index], "|");
for (int j = 0; j < size; j++)
{
strcat(disp[index], " ");
}
strcat(disp[index], "|");
index++;
}
return index;
}
void BlankColumn()
{
for (int i = 0; i < 2*size+3; i++)
{
strcat(disp, " ");
}
}
int LineBack(int index)
{
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size + 1; j++)
{
strcat(disp[index], " ");
}
strcat(disp[index], "|");
index++;
}
return index;
}
int LineFront(int index)
{
for (int i = 0; i < size; i++)
{
strcat(disp[index], "|");
for (int j = 0; j < size + 1; j++)
{
strcat(disp[index], " ");
}
index++;
}
return index;
}
int DashFront(int index)
{
int i;
for (i = 0; i < size; i++)
{
strcat(disp[index], "-");
}
for (i; i < size + 2; i++)
{
strcat(disp[index], " ");
}
index++;
return index;
}
int DashMiddle(int index)
{
strcat(disp[index], " ");
for (int i = 0; i < size; i++)
{
strcat(disp[index], "-");
}
strcat(disp[index], " ");
index++;
return index;
}
};
/*int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)*/
int main(int argc, char * argv)
{
char s = ' ';
int i;
int result;
LCD* myLCD = new LCD();
//get size
scanf( "%c", &s );
while (true)
{
while (s == ' ')
result = scanf( "%c", &s );
i = atoi(&s);
//check to see if it's not 10:
if (i == 1)
{
result = scanf( "%c", &s );
if (s != ' ')
{
i *=10;
i += atoi(&s);
}
}
else if (i == 0) //check for exit condition
{
result = scanf( "%c", &s );
while (s == ' ')
result = scanf( "%c", &s );
if (s == '0')
{
//check for blank line:
result = scanf( "%c", &s );
while (s != '\n')
{
if (s != ' ')
{
printf("error in input line");
break;
}
result = scanf( "%c", &s );
}
return 0;
}
}
if ( (i < 1) || (i > 10) )
{
printf("error: size must be between 1 and 10");
return 0;
}
myLCD->SetSize(i);
//get first char
result = scanf( "%c", &s );
while (s == ' ')
result = scanf( "%c", &s );
//get the rest of the string
int count=0;
while (s != '\n')
{
if (count == 
{
printf("error: number must be between 0 and 99 999 999");
return 0;
}
bool getnewLine=true;
if ( (s < '0') || (s > '9'))
{
if (s == ' ') //if it's just a blank line at the end, ignore it
{
while (s == ' ')
result = scanf( "%c", &s );
if (s == '\n')
{
getnewLine=false;
continue;
}
}
printf("error: non-numeric characters in line");
return 0;
}
myLCD->AddNumber(atoi(&s));
count++;
if (getnewLine)
result = scanf( "%c", &s );
}
myLCD->EndLine();
//move the next line
result = scanf( "%c", &s );
}
return 0;
}
[/cpp]
Posted: Tue May 11, 2004 5:01 am
by GreenPenInc
I actually got mine accepted, first try. It was very gratifying.
That code above is at least twice as long as it needs to be, btw.
Hints? Consider: for a given number (like "12345") you have to print the entire top row before moving on to the top column, then the middle row, then the bottom column and finally the bottom row. Your method will thus need to accept the entire string of the number, in addition to a parameter telling the size (so it knows how much to repeat). Good luck!