Page 6 of 15

Posted: Wed Oct 27, 2004 1:04 am
by afonsocsc
Hello,
try this input:
10 99999999
10 12345678

Posted: Wed Oct 27, 2004 1:32 am
by afonsocsc
Hi,
I did a diff with your output and mine and here's the result:
Your program is printing one extra blank line in the beginning, and is adding one extra space at the end of each line.

Hope it helps

Posted: Mon Nov 01, 2004 9:10 pm
by randomtaiwanese
afonsocsc wrote:Hello,
try this input:
10 99999999
10 12345678
it works... with the new code, which is posted in the other topic
but i still get WA :(

Posted: Mon Nov 01, 2004 9:11 pm
by randomtaiwanese
afonsocsc wrote:Hi,
I did a diff with your output and mine and here's the result:
Your program is printing one extra blank line in the beginning, and is adding one extra space at the end of each line.

Hope it helps
this is new code, fixed the problems u have mentioned, but still WA :(

[java]
import java.io.IOException;
import java.util.StringTokenizer;

class Main
{
String[][] lcd;
int count=1;
int[] num;
int size, length;
char[] chars = new char[3];
final char space = ' ';
static String ReadLn(int maxLg)
{
byte lin[]=new byte[maxLg];
int lg=0,car=-1;
String line="";
try
{
while(lg<maxLg)
{
car=System.in.read();
if ((car<0)||(car=='\n'))
{
break;
}
lin[lg++]+=car;
}
}
catch(IOException e)
{
return(null);
}
if ((car<0)&&(lg==0))
{
return(null);
}
return (new String (lin, 0, lg));
}
public static void main(String[] args)
{
Main newMain = new Main();
newMain.start();
}
void start()
{
String input;
StringTokenizer tokenizer;
String m, n;
lcd = new String[11][3];
while ((input = Main.ReadLn (65535)) != null)
{
tokenizer=new StringTokenizer (input);
m=tokenizer.nextToken();
n=tokenizer.nextToken();
if((Integer.parseInt(m)==0)&&(Integer.parseInt(n)==0))
{
//here start drawing
for(int i=1;i<count;i++)
{
//System.out.println("");
size = Integer.parseInt(lcd[1]);
if(size>10)
break;
String str = lcd[2];
length = str.length();
num = new int[length];
for(int j=0;j<length;j++)
{
num[j] = Integer.parseInt(new Character(str.charAt(j)).toString());
}
//draw first line
setChar(0,0);
setChar(2,0);
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==4))
setChar(1,0);
else
setChar(1,2);
draw();
if(j!=length-1)
drawBlank();
}
//second line
setChar(1,0);
for(int u=0;u<size;u++)
{
System.out.println("");
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==2)||(num[j]==3)||(num[j]==7))
setChar(0,0);
else
setChar(0,1);
if((num[j]==5)||(num[j]==6))
setChar(2,0);
else
setChar(2,1);
draw();
if(j!=length-1)
drawBlank();
}
}
System.out.println("");
//third line
setChar(0,0);
setChar(2,0);
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==7)||(num[j]==0))
setChar(1,0);
else
setChar(1,2);
draw();
if(j!=length-1)
drawBlank();
}
//forth line
setChar(1,0);
for(int u=0;u<size;u++)
{
System.out.println("");
for(int j=0;j<length;j++)
{
if(num[j]==2)
setChar(2,0);
else
setChar(2,1);
if((num[j]==2)||(num[j]==6)||(num[j]==8)||(num[j]==0))
setChar(0,1);
else
setChar(0,0);
draw();
if(j!=length-1)
drawBlank();
}
}
System.out.println("");
//fifth line
setChar(0,0);
setChar(2,0);
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==4)||(num[j]==7))
setChar(1,0);
else
setChar(1,2);
draw();
if(j!=length-1)
drawBlank();
}
if(i!=count-1)
{
System.out.println("");
System.out.println("");
}
}
System.out.println("");
break;
}
else
{
lcd[count][1]=m;
lcd[count][2]=n;
count++;
}
}
}
void drawBlank()
{
System.out.print(space);
}
void setChar(int charnum, int chartype)
{
switch(chartype)
{
case 0:
chars[charnum]=space;
break;
case 1:
chars[charnum]='|';
break;
case 2:
chars[charnum]='-';
break;
}
}
void draw()
{
System.out.print(chars[0]);
for(int l=0;l<size;l++)
{
System.out.print(chars[1]);
}
System.out.print(chars[2]);
}
}[/java]

Posted: Tue Nov 02, 2004 1:42 am
by afonsocsc
Why are you storing the input in an array?
If the input has more than 10 lines (excluding the last), your program will have an ArrayIndexOutOfBoundsException

You should process each line as you read it.

706: can't understand why WA, can someone help me?

Posted: Thu Nov 11, 2004 2:40 am
by .pandre.
hello everyone

I'm having great troubles with this nasty, tricky problem; I think I have the right answers, but the judge doesn't seem to agree with me :(

my ouputs for:
2 12345
3 67890
10 99999999
10 0
5 1094
4 11111
3 18818818
1 0
2 0
3 0
8 31415
2 007
0 0

are:

Code: Select all

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

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

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

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

 - 
| |
   
| |
 - 

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

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

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

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

if you prefer, by replacing the blanks with dots (".") I get this output:

Code: Select all

......--...--........--.
...|....|....|.|..|.|...
...|....|....|.|..|.|...
......--...--...--...--.
...|.|.......|....|....|
...|.|.......|....|....|
......--...--........--.

.---...---...---...---...---.
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
.---.........---...---.......
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
.---.........---...---...---.

.----------...----------...----------...----------...----------...----------...----------...----------.
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
.----------...----------...----------...----------...----------...----------...----------...----------.
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
.----------...----------...----------...----------...----------...----------...----------...----------.

.----------.
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
............
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
.----------.

.........-----...-----.........
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
.................-----...-----.
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
.........-----...-----.........

..................................
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
..................................
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
..................................

.......---...---.........---...---.........---.
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
.......---...---.........---...---.........---.
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
.......---...---.........---...---.........---.

.-.
|.|
...
|.|
.-.

.--.
|..|
|..|
....
|..|
|..|
.--.

.---.
|...|
|...|
|...|
.....
|...|
|...|
|...|
.---.

.--------....................................--------.
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.--------..............--------..............--------.
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.--------....................................--------.

.--...--...--.
|..|.|..|....|
|..|.|..|....|
..............
|..|.|..|....|
|..|.|..|....|
.--...--......

is there any wrong output?
is there something missing?

I would be very glad if a good soul would help me because I've been stuck with this problem for a long time

Posted: Sun Nov 14, 2004 3:31 pm
by Maniac
for problems with the problemset, don't post here but at the forum-part specially meant for that. There you'll also probably find out about other peoples troubles with this problem etc. Good luck!

706 LC-Display Presentation Error

Posted: Mon Nov 15, 2004 5:17 pm
by SePulTribe
I know a PE doesn't mean much to many people but it does to me. I'm stumped as to how to make my output perfect. Here is my code. Please help. Thanks in advance!

[c]#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int factor, digits[8], last, temp, ii, jj, zz;
char toprint, t[2];
char code[10][7] = {
{ 1, 1, 1, 0, 1, 1, 1 }, { 0, 0, 1, 0, 0, 1, 0 },
{ 1, 0, 1, 1, 1, 0, 1 }, { 1, 0, 1, 1, 0, 1, 1 },
{ 0, 1, 1, 1, 0, 1, 0 }, { 1, 1, 0, 1, 0, 1, 1 },
{ 1, 1, 0, 1, 1, 1, 1 }, { 1, 0, 1, 0, 0, 1, 0 },
{ 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 0, 1, 1 }
};

t[1] = '\0';
while (scanf("%d ", &factor) != EOF)
{
if (!factor)
break;
last = 0;
while ((toprint = (char)getc(stdin)) != '\n' && toprint != EOF)
{
t[0] = toprint;
digits[last++] = atoi(t);
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][0]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][1]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][2]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][3]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][4]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][5]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][6]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n\n");
}
return 0;
}
[/c]

Posted: Tue Nov 16, 2004 5:49 am
by CodeMaker
Hi try this out :)

here '*' means space :wink:

Code: Select all


your output:

3 0

*---
|***|
|***|
|***|
****
|***|
|***|
|***|
*---

my output:

3 0

*---*
|***|
|***|
|***|
*****
|***|
|***|
|***|
*---*


check out the last asteriks, u cant just keep it empty , u have to fill the whole size with space or either '|' or '-'

i hope u will pass PE this time......and u know how to modify ur code....

Goodluck :wink: 

Doesn't work

Posted: Tue Nov 16, 2004 5:38 pm
by SePulTribe
Hmm did what you said, but it still didn't work. :(

Here's my modified code:
[c]#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int factor, digits[8], last, temp, ii, jj, zz;
char toprint, t[2];
char code[10][7] = {
{ 1, 1, 1, 0, 1, 1, 1 }, { 0, 0, 1, 0, 0, 1, 0 },
{ 1, 0, 1, 1, 1, 0, 1 }, { 1, 0, 1, 1, 0, 1, 1 },
{ 0, 1, 1, 1, 0, 1, 0 }, { 1, 1, 0, 1, 0, 1, 1 },
{ 1, 1, 0, 1, 1, 1, 1 }, { 1, 0, 1, 0, 0, 1, 0 },
{ 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 0, 1, 1 }
};

t[1] = '\0';
while (scanf("%d ", &factor) != EOF)
{
if (!factor)
break;
last = 0;
while ((toprint = (char)getc(stdin)) != '\n' && toprint != EOF)
{
t[0] = toprint;
digits[last++] = atoi(t);
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][0]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][1]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][2]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][3]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][4]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][5]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][6]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n\n");
}
return 0;
}
[/c]

Posted: Tue Nov 16, 2004 6:51 pm
by SePulTribe
Hey thanks! It works on this judge but not the programming-challenges one. Haiz. The programming-challenges judge is so irritating.

Posted: Wed Nov 17, 2004 4:38 am
by CodeMaker
Well happy to hear that ur problem is solved....

I did not tried it in programming challenges judge.....but if the problem descriction is same then it should have worked......

but u can try one thing there......cut out newline after the last output. now question is how u will undestand which one is last input?.....

well there is a way, u can print newline before each output except the 1st one and thats not so hard, actually I solved it in this way at the 1st time and this judge gave me PE......then i print newline after each case and got Acc, so there is a possibility that the opposite happens in programming challenges judge.......but dont try anything else, because i dont think that will work

:D well, goodbye and goodluck.......

Posted: Wed Nov 17, 2004 7:54 am
by SePulTribe
Hey thanks but it still doesn't work. I'm so frustrated. :(

706

Posted: Mon Mar 28, 2005 6:11 pm
by rahurprem
Could you please help me with my code? The judge answered "WRONG ANSWER". I don't understand why.

Is there any special input present, what my code didn't consider?
I didn't consider NEGATIVE numbers
I didn't consider SIZE = 0
I didn't consider LEADING ZEROs.

This is my code

Code: Select all


//Wrong answer
#include<stdio.h>
#include<math.h>

char a[10][5][3]=
{
	//ZERO
	' ','-',' ',
	'|',' ','|',
	' ',' ',' ',
	'|',' ','|',
	' ','-',' ',

	//ONE
	' ',' ',' ',
	' ',' ','|',
	' ',' ',' ',
	' ',' ','|',
	' ',' ',' ',


	//TWO
	' ','-',' ',
	' ',' ','|',
	' ','-',' ',
	'|',' ',' ',
	' ','-',' ',

	//THREE
	' ','-',' ',
	' ',' ','|',
	' ','-',' ',
	' ',' ','|',
	' ','-',' ',

	//FOUR
	' ',' ',' ',
	'|',' ','|',
	' ','-',' ',
	' ',' ','|',
	' ',' ',' ',

	//FIVE
	' ','-',' ',
	'|',' ',' ',
	' ','-',' ',
	' ',' ','|',
	' ','-',' ',

	//SIX
	' ','-',' ',
	'|',' ',' ',
	' ','-',' ',
	'|',' ','|',
	' ','-',' ',

	//SEVEN
	' ','-',' ',
	' ',' ','|',
	' ',' ',' ',
	' ',' ','|',
	' ',' ',' ',

	//EIGHT
	' ','-',' ',
	'|',' ','|',
	' ','-',' ',
	'|',' ','|',
	' ','-',' ',

	//NINE
	' ','-',' ',
	'|',' ','|',
	' ','-',' ',
	' ',' ','|',
	' ','-',' ',

};
	
int main()
{
//	freopen("706.in","r",stdin);
//	freopen("706.txt","w",stdout);

	int s, n;
	int backup,digitCount,i,j;
	int process;
	int power;
	int k,l,x;
	int Count=0;
	int flag=0;
	int flag2=0;
	int linef=0;


	while( (scanf("%d%d",&s,&n)==2)&&(s||n))
	{
		if(flag2)
			printf("\n");
		flag2=1;
		backup = n;
		digitCount = (int)floor(log10(n))+1;

		for(i=0; i<5; )
		{	
			flag=0;
			for(j=digitCount-1; j>=0; j--)
			{
				if(flag)
					printf(" ");
				flag=1;

				power = (int)pow(10,j);
				
				process = n/power;
				n = n%power;
				
				int minus=0;
				int line=0;
				
				for(x=0; x<3; x++)
				{
					if(a[process][i][x]=='-')
					{
						minus=1;
						break;
					}
					if(a[process][i][x]=='|')
					{
						line=1;						
						break;
					}
				}

				if(minus)
				{
					minus=0;

					for(k=0; k<3; k++)
					{						
						if(a[process][i][k]=='-'||(a[process][i][k]==' '&&k==1))
						{
							for(l=0; l<s; l++)
							{
								printf("%c",a[process][i][k]);
							}
						}
						else
						{
							printf("%c",a[process][i][k]);
						}						
					}							
				}
				else if(line)
				{
					linef =1;
					if(Count<s)
					{					
						line=0;
						for(k=0; k<3; k++)
						{
							if(a[process][i][k]=='|')
							{
								printf("%c",a[process][i][k]);
							}
							else
							{
								if(a[process][i][k]==' '&&k==1)
								{
									for(l=0; l<s; l++)
									{
										printf("%c",a[process][i][k]);
									}
								}
								else
								{
									printf("%c",a[process][i][k]);
								}							
							}
						}						
					}										
				}							
				else
				{
					for(k=0; k<3; k++)
					{
						if(a[process][i][k]==' '&&k==1)
						{
							for(l=0; l<s; l++)
							{
								printf("%c",a[process][i][k]);
							}
						}
						else
						{
							printf("%c",a[process][i][k]);
						}							
					}										
				}
				if(Count==s)Count=0;				
			}
			printf("\n");
			if(linef)
			{
				Count++;
				linef=0;
			}
			n = backup;
			
			if(Count==s)Count=0;
			if(Count==0){i++;}						
		}		
	}
	return 0;
}


Posted: Mon Mar 28, 2005 6:58 pm
by Raiyan Kamal
You have to consider leading zeroes. If there is one or more leading zeroes, you have to show them in the output