706 - LCD Display

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

Moderator: Board moderators

regina
New poster
Posts: 4
Joined: Mon May 10, 2004 11:57 pm

but why wrong?

Post by regina »

my code may be too long, but still, why 'wrong answer' if it gets the job done?

GreenPenInc
Learning poster
Posts: 53
Joined: Sat May 01, 2004 9:31 pm
Contact:

Re: Still Not accepted

Post by GreenPenInc »

Ok, I looked at your solution and it's not correct.

1) You don't leave a blank line between numbers.
2) Try the input file with 8 31415 added at the end. Your output should be this (my output):

Code: Select all

      --   --        -- 
   |    |    | |  | |   
   |    |    | |  | |   
      --   --   --   -- 
   | |       |    |    |
   | |       |    |    |
      --   --        --

 ---   ---   ---   ---   --- 
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---       
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   ---

 --------                                    -------- 
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
 --------              --------              -------- 
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
 --------                                    --------

Instead, yours outputs this:

Code: Select all

      --  --         -- 
   |    |    | |  | |   
   |    |    | |  | |   
      --  --    --   -- 
   | |       |    |    |
   | |       |    |    |
      --  --         -- 
 ---   ---   ---   ---   --- 
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---       
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   --- 
--------                                     -------- 
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
--------               --------              -------- 
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
--------                                     -------- 
See how your 3 is smooshed up against the left edge? That's part of the problem. I'm not sure where in your code is causing that, as I admit I don't understand your code, but now that you at least know where you're going wrong you should have a better chance of fixing it. :)

(Also if you're posting code, remember to click Disable Smilies. Makes it easier for someone trying to help you to get your code :))
_-(GPI)-_

"Finally I have freed myself from the clutches of the garbage fairy!"

regina
New poster
Posts: 4
Joined: Mon May 10, 2004 11:57 pm

Post by regina »

Hi - thank you so much! My program just got accepted (with a P.E., but I really don't care about that so much) :lol: . The picture in the problem description threw me off -- it would've been better if the spaces were substituted with * or something... If it wasn't for your help, I would've probably never even seen it! :o

BTW -- my code is pretty easy - instead of focusing on full numbers, I reduced them to dashes and vertical lines, so every time a number came through, I just threw out a bunch of dashes and lines that corresponded to that number. It was pretty easy to write that way. :D

cometx
New poster
Posts: 1
Joined: Sat May 15, 2004 1:25 am

706-WA-I don't agree to it

Post by cometx »

The only thing in my code I suspect is how I open the input file, I use ifstream instead of stdin. How do you open the input file the way they want, please advise. :roll:

GreenPenInc
Learning poster
Posts: 53
Joined: Sat May 01, 2004 9:31 pm
Contact:

Post by GreenPenInc »

You have to use standard input for input and output to standard output. If you are using unix or linux, do:

Code: Select all

prompt$ ./a.out < input
Where a.out is the name of your compiled binary and input is a file containing the test input.
_-(GPI)-_

"Finally I have freed myself from the clutches of the garbage fairy!"

GreenPenInc
Learning poster
Posts: 53
Joined: Sat May 01, 2004 9:31 pm
Contact:

Post by GreenPenInc »

Glad I could help. :)

btw, check out a program called figlet. If you use Linux it's probably already installed. It's a fun little thing to play around with, and is similar to this problem.
_-(GPI)-_

"Finally I have freed myself from the clutches of the garbage fairy!"

Eduard
Experienced poster
Posts: 183
Joined: Fri Sep 26, 2003 2:54 pm
Location: Armenia,Yerevan

Post by Eduard »

Hi.
To Pasq.
On your program Jakie can have some ' ' .
Thats way you need this.
And yuo will get AC(P.E.).
[pascal]while wie>0 do
begin
1:
for i:=1 to length(jakie) do
if jakie=' ' then begin delete(jakie,i,1);goto 1;end;
jakie:=' '+jakie;

[/pascal]

The whole code will be.
[pascal]
program dupa;
label 1;
var
wie :longint;
jakie :string;
i,j :longint;
n :longint;
puste,pelne :string;
begin
{ assign(output,'acm706.txt');
rewrite(output);}
readln(wie,jakie);
while wie>0 do
begin
1:
for i:=1 to length(jakie) do
if jakie=' ' then begin delete(jakie,i,1);goto 1;end;
jakie:=' '+jakie;
pelne:='';
puste:='';
n:=length(jakie);
for i:=1 to wie do
begin
puste:=puste+' ';
pelne:=pelne+'-';
end;
for i:=2 to n do
begin
write(' ');
case jakie of
'1':write(puste);
'4':write(puste);
else write(pelne);
end;
write(' ');
if i<>n then write(' ');
end;
writeln;
for j:=1 to wie do
begin
for i:=2 to n do
begin
case jakie of
'4':write('|');
'5':write('|');
'6':write('|');
'8':write('|');
'9':write('|');
'0':write('|');
else write(' ');
end;
write(puste);
case jakie of
'1':write('|');
'2':write('|');
'3':write('|');
'4':write('|');
'7':write('|');
'8':write('|');
'9':write('|');
'0':write('|');
else write(' ');
end;
if i<>n then write(' ');
end;
writeln;
end;
for i:=2 to n do
begin
write(' ');
case jakie of
'1':write(puste);
'7':write(puste);
'0':write(puste);
else write(pelne);
end;
write(' ');
if i<>n then write(' ');
end;
writeln;
for j:=1 to wie do
begin
for i:=2 to n do
begin
case jakie of
'2':write('|');
'6':write('|');
'8':write('|');
'0':write('|');
else write(' ');
end;
write(puste);
case jakie of
'1':write('|');
'3':write('|');
'4':write('|');
'5':write('|');
'6':write('|');
'7':write('|');
'8':write('|');
'9':write('|');
'0':write('|');
else write(' ');
end;
if i<>n then write(' ');
end;
writeln;
end;
for i:=2 to n do
begin
write(' ');
case jakie of
'1':write(puste);
'4':write(puste);
'7':write(puste);
else write(pelne);
end;
write(' ');
if i<>n then write(' ');
end;
writeln;
readln(wie,jakie);
if wie<>0
then
writeln;
end;
end.
[/pascal]
someone who like to solve informatic problems.
http://acm.uva.es/cgi-bin/OnlineJudge?AuthorInfo:29650

Ascarbek
New poster
Posts: 1
Joined: Sun Jun 20, 2004 8:56 pm
Location: Almaty, Kazakhstan
Contact:

706 LC-Display (Wrong Answer?!)

Post by Ascarbek »

People please tell me what's wrong with this code???

program Project1;
{$APPTYPE console}
Var s,n : integer;
a : array[1..10] of byte;
const sh : array[0..9,1..7] of char =
(
('-','|','|',' ','|','|','-'),
(' ',' ','|',' ',' ','|',' '),
('-',' ','|','-','|',' ','-'),
('-',' ','|','-',' ','|','-'),
(' ','|','|','-',' ','|',' '),
('-','|',' ','-',' ','|','-'),
('-','|',' ','-','|','|','-'),
('-',' ','|',' ',' ','|',' '),
('-','|','|','-','|','|','-'),
('-','|','|','-',' ','|','-')
);

Procedure Save;
Var cur : char;
j,i,k : integer;
Begin
For i:=1 to n-1 do
Begin
write(' ');
cur:=sh[a,1];
For j:=1 to s do
write(cur);
write(' ');
End;
i:=n;
write(' ');
cur:=sh[a,1];
For j:=1 to s do
write(cur);
write(' ');

writeln('');
For k:=1 to s do
Begin
For i:=1 to n-1 do
Begin
write(sh[a,2]);
For j:=1 to s do
write(' ');
write(sh[a,3]+' ');
End;
i:=n;
write(sh[a,2]);
For j:=1 to s do
write(' ');
write(sh[a,3]);
writeln('');
End;
For i:=1 to n-1 do
Begin
write(' ');
cur:=sh[a,4];
For j:=1 to s do
write(cur);
write(' ');
End;
i:=n;
write(' ');
cur:=sh[a,4];
For j:=1 to s do
write(cur);
write(' ');
writeln('');
For k:=1 to s do
Begin
For i:=1 to n-1 do
Begin
write(sh[a,5]);
For j:=1 to s do
write(' ');
write(sh[a,6]+' ');
End;
i:=n;
write(sh[a[i],5]);
For j:=1 to s do
write(' ');
write(sh[a[i],6]);
writeln('');
End;
For i:=1 to n-1 do
Begin
write(' ');
cur:=sh[a[i],7];
For j:=1 to s do
write(cur);
write(' ');
End;
i:=n;
write(' ');
cur:=sh[a[i],7];
For j:=1 to s do
write(cur);
write(' ');
writeln('');
End;
{-------------------------------------------------------------------------}
Procedure Load;
Var inp : string;
i,j : integer;
Begin
readln(inp);
Repeat
val(copy(inp,1,pos(' ',inp)-1),s,i);
For i:=pos(' ',inp)+1 to length(inp) do
val(inp[i],a[i-pos(' ',inp)],j);
n:=i-pos(' ',inp)-1;
Save;
writeln('');
readln(inp);
Until(inp[1]='0');
End;
{-------------------------------------------------------------------------}
begin
Load;
end.

jagadish
Learning poster
Posts: 90
Joined: Mon Feb 16, 2004 8:53 pm
Location: Bangalore INDIA

Post by jagadish »

i dont understand pascal but i complied your program and found that its
far from being correct ..make sure that you atleast check your code with
sample inputs before making a post
if u can think of it .. u can do it in software.

tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Re: 706 WA

Post by tan_Yui »

I executed your code, and got wrong output.
Check your code again.
If you can't find wrong point of your output, check with other compiler or text-editor will lead you better.

bellidoks
New poster
Posts: 3
Joined: Mon Jul 19, 2004 11:04 pm

706.Why another WA?

Post by bellidoks »

I have already tried thousands of inputs and I haven't found where my program fails, yet. Can anybody tell me what is wrong in my code or give me any critial input which makes my program fail, plz?

Here is the code:
[cpp]#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

char rep[10][5][3]={{{' ',' ',' '},{' ',' ','|'},{' ',' ',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{' ',' ','|'},{' ','-',' '},{'|',' ',' '},{' ','-',' '}},
{{' ','-',' '},{' ',' ','|'},{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
{{' ',' ',' '},{'|',' ','|'},{' ','-',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{'|',' ',' '},{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
{{' ','-',' '},{'|',' ',' '},{' ','-',' '},{'|',' ','|'},{' ','-',' '}},
{{' ','-',' '},{' ',' ','|'},{' ',' ',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{'|',' ','|'},{' ','-',' '},{'|',' ','|'},{' ','-',' '}},
{{' ','-',' '},{'|',' ','|'},{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
{{' ','-',' '},{'|',' ','|'},{' ',' ',' '},{'|',' ','|'},{' ','-',' '}}};
int MAX_SIZEr=23;
int MAX_SIZEc=103;
char matrix[23][103];
int nrow=0,ncol=MAX_SIZEc-1;

void print_matrix(){
if(ncol<MAX_SIZEc-1){
for(int u=0;u<nrow;u++){
for(int t=ncol+2;t<MAX_SIZEc;t++){
cout<<matrix[t];
}
cout<<endl;
}
}
}

void draw(int digit,int size){
int nr=0,j;
if(digit!=0){
digit=digit-1;
}else{
digit=9;
}
//vertical de la dreta del digit
for(j=0;j<5;j++){
if(rep[digit][j][2]=='|'){
for(int h=0;h<size;h++){
matrix[nr+h][ncol]='|';
}
nr=nr+size;
}else if(rep[digit][j][2]==' '){
if(rep[digit][j][0]=='|'){
for(int k=0;k<size;k++){
matrix[nr][ncol]=rep[digit][j][2];
nr++;
}
}else{
matrix[nr][ncol]=' ';
nr++;
}
}
}
ncol--;
//horitzontal del mig del digit
nr=0;
for(j=0;j<5;j++){
if(rep[digit][j][2]=='|'||rep[digit][j][0]=='|'){
for(int g=0;g<size;g++){
for(int d=0;d<size;d++){
matrix[nr][ncol-d]=rep[digit][j][1];
}
nr++;
}
}else if(rep[digit][j][2]==' '&&rep[digit][j][0]==' '){
for(int d=0;d<size;d++){
matrix[nr][ncol-d]=rep[digit][j][1];
}
nr++;
}
}
ncol=ncol-size;
//vertical de l'esquerra del digit
nr=0;
for(j=0;j<5;j++){
if(rep[digit][j][0]=='|'){
for(int h=0;h<size;h++){
matrix[nr+h][ncol]='|';
}
nr=nr+size;
}else if(rep[digit][j][0]==' '){
if(rep[digit][j][2]=='|'){
for(int b=0;b<size;b++){
matrix[nr][ncol]=rep[digit][j][0];
nr++;
}
}else{
matrix[nr][ncol]=' ';
nr++;
}
}
}
ncol--;
}

void add_column(int size){
int i;
for(i=0;i<size*2+3;i++){
matrix[ncol]=' ';
}
ncol--;
}

int main(){
int size,number,digit;
cin>>size>>number;
while(size!=0||number!=0){
if(size>0){
nrow=size*2+3;
if(number!=0){
while(number>0){
digit=number%10;
number=number/10;
draw(digit,size);
add_column(size);
}
}else{
draw(number,size);
ncol--;
}
print_matrix();
nrow=0;
ncol=MAX_SIZEc-1;
}
cin>>size>>number;
cout<<endl;
}
return 0;
}[/cpp]

afonsocsc
New poster
Posts: 34
Joined: Mon Mar 24, 2003 1:15 am
Location: Portugal, Lisbon

Post by afonsocsc »

Try this:
10 99999999

titan1009
New poster
Posts: 1
Joined: Wed Aug 04, 2004 3:10 am

706~Help me please

Post by titan1009 »

I don't know what's wrong with my code. Can anybody help me? Thanks in advance~ :P

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

void process1(int number , int s)
{
int k ;
printf(" ");
if ((number == 1) || (number == 4)){
for (k = 0 ; k < s ; k++)
printf(" ");
}
else {
for (k = 0 ; k < s ; k++)
printf("-");
}
printf(" ");
}

void process3(int number , int s)
{
int k ;
printf(" ");
if ((number == 0) || (number == 1) || (number == 7) ){
for (k = 0 ; k < s ; k++)
printf(" ");
}
else {
for (k = 0 ; k < s ; k++)
printf("-");
}
printf(" ");
}

void process5(int number , int s)
{
int k ;
printf(" ");
if ((number == 1) || (number == 4) || (number == 7)){
for (k = 0 ; k < s ; k++)
printf(" ");
}
else {
for (k = 0 ; k < s ; k++)
printf("-");
}
printf(" ");
}

void process2(int number , int s)
{
int k ;
if ((number == 1 ) || (number == 2 ) || (number == 3 ) || (number == 7 )){
for (k = 0 ; k <= s ; k++)
printf(" ");
printf("|");
}
else if ((number == 4 ) || (number == 8 ) || (number == 9 ) || (number == 0 )){
printf("|");
for (k = 0 ; k < s ; k++)
printf(" ");
printf("|");
}
else if ((number == 5 ) || (number == 6 )){
printf("|");
for (k = 0 ; k <= s ; k++)
printf(" ");
}
}

void process4(int number , int s)
{
int k ;
if ((number == 1 ) || (number == 3 ) || (number == 4 ) || (number == 5 ) || (number == 7 ) || (number == 9 )){
for (k = 0 ; k <= s ; k++)
printf(" ");
printf("|");
}
else if ((number == 0 ) || (number == 6 ) || (number == 8 )){
printf("|");
for (k = 0 ; k < s ; k++)
printf(" ");
printf("|");
}
else if (number == 2 ){
printf("|");
for (k = 0 ; k <= s ; k++)
printf(" ");
}
}

int main()
{
char num[10] ;
int s , n[10] , i , j , k ;
while (1){
scanf("%d%s" , &s , &num);
if (( s == 0)&&(strcmp(num,"0") == 0))
break ;
j = strlen(num);
/*transform*/
for ( i = 0 ; i < j ; i++)
n = num - '0' ;
/*process1*/
for ( i = 0 ; i < j ; i++){
process1(n , s) ;
if ( i == (j - 1))
printf("\n");
else
printf(" ");
}
/*process2*/
for ( k = 0 ; k < s ; k++){
for ( i = 0 ; i < j ; i++){
process2(n , s);
if (i != (j -1))
printf(" ");
else
printf("\n");
}
}
/*process3*/
for ( i = 0 ; i < j ; i++){
process3(n , s) ;
if ( i == (j - 1))
printf("\n");
else
printf(" ");
}
/*process4*/
for ( k = 0 ; k < s ; k++){
for ( i = 0 ; i < j ; i++){
process4(n , s) ;
if ( i == (j - 1))
printf("\n");
else
printf(" ");
}
}
/*process5*/
for ( i = 0 ; i < j ; i++){
process5(n , s) ;
if ( i == (j - 1))
printf("\n");
else
printf(" ");
}
}
return 1;
}

watershed
New poster
Posts: 13
Joined: Thu Aug 05, 2004 9:14 am

Re: 706~Help me please

Post by watershed »

I got AC(P.E) in this problem.
I only change【printf】for【putchar】in C.
You can try it......

gmenhorn
New poster
Posts: 4
Joined: Sat Aug 07, 2004 4:31 pm

706 - This problem is crazy!

Post by gmenhorn »

Can someone please help me figure out what is going on with this problem. Do we have to handle wrap for numbers that won't fit in 80 columns? (I've tried it with and without wrap to no avail). Every test case that I can think up works fine. Is the problem statement really that clear that I'm missing something so obvious? Thanks a million for your help!

Here is my input file:

Code: Select all

2 12345
3 67890
10 99999999
10 0
5 1094
4 11111
3 18818818
1 0
2 0
3 0
8 31415
0 0
Here is my output file (assuming wrap at 80 chars):

Code: Select all

      --   --        -- 
   |    |    | |  | |   
   |    |    | |  | |   
      --   --   --   -- 
   | |       |    |    |
   | |       |    |    |
      --   --        -- 

 ---   ---   ---   ---   --- 
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---       
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   --- 

 ----------   ----------   ----------   ----------   ----------   ---------- 
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
|          | |          | |          | |          | |          | |          |
 ----------   ----------   ----------   ----------   ----------   ---------- 
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
           |            |            |            |            |            |
 ----------   ----------   ----------   ----------   ----------   ---------- 

 ----------   ---------- 
|          | |          |
|          | |          |
|          | |          |
|          | |          |
|          | |          |
|          | |          |
|          | |          |
|          | |          |
|          | |          |
|          | |          |
 ----------   ---------- 
           |            |
           |            |
           |            |
           |            |
           |            |
           |            |
           |            |
           |            |
           |            |
           |            |
 ----------   ---------- 

 ---------- 
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
            
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
|          |
 ---------- 

         -----   -----         
      | |     | |     | |     |
      | |     | |     | |     |
      | |     | |     | |     |
      | |     | |     | |     |
      | |     | |     | |     |
                 -----   ----- 
      | |     |       |       |
      | |     |       |       |
      | |     |       |       |
      | |     |       |       |
      | |     |       |       |
         -----   -----         

                                  
     |      |      |      |      |
     |      |      |      |      |
     |      |      |      |      |
     |      |      |      |      |
                                  
     |      |      |      |      |
     |      |      |      |      |
     |      |      |      |      |
     |      |      |      |      |
                                  

       ---   ---         ---   ---         --- 
    | |   | |   |     | |   | |   |     | |   |
    | |   | |   |     | |   | |   |     | |   |
    | |   | |   |     | |   | |   |     | |   |
       ---   ---         ---   ---         --- 
    | |   | |   |     | |   | |   |     | |   |
    | |   | |   |     | |   | |   |     | |   |
    | |   | |   |     | |   | |   |     | |   |
       ---   ---         ---   ---         --- 

 - 
| |
   
| |
 - 

 -- 
|  |
|  |
    
|  |
|  |
 -- 

 --- 
|   |
|   |
|   |
     
|   |
|   |
|   |
 --- 

 --------                                    -------- 
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
         |          | |        |          | |         
 --------              --------              -------- 
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
         |          |          |          |          |
 --------                                    -------- 


Post Reply

Return to “Volume 7 (700-799)”