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

winkle
New poster
Posts: 3
Joined: Thu Jun 08, 2006 2:56 pm

706 WA

Post by winkle »

Any help on why this isn't accepted would be very appreciated:

Code: Select all

Code removed.
Last edited by winkle on Thu Dec 21, 2006 10:01 am, edited 1 time in total.
farzane
New poster
Posts: 26
Joined: Thu Jun 15, 2006 9:26 am

706

Post by farzane »

I got PE.what's wrorng whit my code:

Code: Select all

#include<iostream.h>
#include<string.h>



char digits[10][5][4];

void main(){
strcpy(digits[0][0],"-\0");
strcpy(digits[0][1],"||\0");
strcpy(digits[0][2]," \0");
strcpy(digits[0][3],"||\0");
strcpy(digits[0][4],"-\0");

strcpy(digits[1][0]," \0");
strcpy(digits[1][1]," |\0");
strcpy(digits[1][2]," \0");
strcpy(digits[1][3]," |\0");
strcpy(digits[1][4]," \0");

strcpy(digits[2][0],"-\0");
strcpy(digits[2][1]," |\0");
strcpy(digits[2][2],"-\0");
strcpy(digits[2][3],"| \0");
strcpy(digits[2][4],"-\0");


strcpy(digits[3][0],"-\0");
strcpy(digits[3][1]," |\0");
strcpy(digits[3][2],"-\0");
strcpy(digits[3][3]," |\0");
strcpy(digits[3][4],"-\0");


strcpy(digits[4][0]," \0");
strcpy(digits[4][1],"||\0");
strcpy(digits[4][2],"-\0");
strcpy(digits[4][3]," |\0");
strcpy(digits[4][4]," \0");

strcpy(digits[5][0],"-\0");
strcpy(digits[5][1],"| \0");
strcpy(digits[5][2],"-\0");
strcpy(digits[5][3]," |\0");
strcpy(digits[5][4],"-\0");


strcpy(digits[6][0],"-\0");
strcpy(digits[6][1],"| \0");
strcpy(digits[6][2],"-\0");
strcpy(digits[6][3],"||\0");
strcpy(digits[6][4],"-\0");

strcpy(digits[7][0],"-\0");
strcpy(digits[7][1]," |\0");
strcpy(digits[7][2]," \0");
strcpy(digits[7][3]," |\0");
strcpy(digits[7][4]," \0");


strcpy(digits[8][0],"-\0");
strcpy(digits[8][1],"||\0");
strcpy(digits[8][2],"-\0");
strcpy(digits[8][3],"||\0");
strcpy(digits[8][4],"-\0");

strcpy(digits[9][0],"-\0");
strcpy(digits[9][1],"||\0");
strcpy(digits[9][2],"-\0");
strcpy(digits[9][3]," |\0");
strcpy(digits[9][4],"-\0");

    int s,i,k,digi,p;
    char str[20];	
	cin>>s>>str;
	while(s!=0 ){

	
		for(i=0;str[i];i++){
			digi=str[i]-'0';
			
			cout<<" ";//digits[digi][0][0];
			for(k=0;k<s;k++)
				cout<<digits[digi][0][0];
			cout<<"  ";//digits[digi][0][2]<<" ";
		}
		cout<<endl;

		for(k=0;k<s;k++){
			for(i=0;str[i];i++){
				digi=str[i]-'0';
				
				cout<<digits[digi][1][0];
				for(p=0;p<s;p++)
					cout<<" ";//digits[digi][1][1];
				cout<<digits[digi][1][1]<<" ";
			}
			cout<<endl;
		}

		for(i=0;str[i];i++){
			digi=str[i]-'0';
			
			cout<<" ";//digits[digi][2][0];
			for(k=0;k<s;k++)
				cout<<digits[digi][2][0];
			cout<<"  ";//digits[digi][2][2]<<" ";
		}
		cout<<endl;

        for(k=0;k<s;k++){
			for(i=0;str[i];i++){
				digi=str[i]-'0';
				
				cout<<digits[digi][3][0];
				for(p=0;p<s;p++)
					cout<<" ";//digits[digi][3][1];
				cout<<digits[digi][3][1]<<" ";
			}
			cout<<endl;
		}


        for(i=0;str[i];i++){
			digi=str[i]-'0';
			
			cout<<" ";//digits[digi][4][0];
			for(k=0;k<s;k++)
				cout<<digits[digi][4][0];
			cout<<"  ";//digits[digi][4][2]<<" ";
		}
		cout<<endl;
	    cout<<endl;
		cin>>s>>str;
	
	}
}
farzane
New poster
Posts: 26
Joined: Thu Jun 15, 2006 9:26 am

Post by farzane »

you should consider leading zeros.
I mean when input is 007 output shouldn't be as same as when input is 7.
you could get the No in string and for checking end of inputs it is enough just to check s.
I hope it could help. :wink:
winkle
New poster
Posts: 3
Joined: Thu Jun 08, 2006 2:56 pm

Post by winkle »

farzane wrote:you should consider leading zeros.
I mean when input is 007 output shouldn't be as same as when input is 7.
Not true, this is what my accepted program does. Both these cases should print out a 7.
farzane wrote: you could get the No in string and for checking end of inputs it is enough just to check s.
I hope it could help. :wink:
I don't understand what you mean here. "0 3" as input should not end the program.
rmpowell77
New poster
Posts: 5
Joined: Fri Aug 25, 2006 11:42 pm

Post by rmpowell77 »

Note: this only applies to the http://www.programming-challenges.com site:

If you take a look at the statistics for this problem on the programming challenges, you'll notice this:

Times submitted 5335
Times solved 0
Users submitted 1024
Users solved 0
Best time never solved

Probably there is something wrong with the judge script on the site.
junhee
New poster
Posts: 1
Joined: Mon Aug 28, 2006 8:45 pm

706 - WA... Help Me!!

Post by junhee »

Code: Select all

/*	@BEGIN_OF_SOURCE_CODE	*/

#include <iostream>
#include <string>
using namespace std;

#define MAX_DIGIT	8
#define MAX_S		10

#define bar1(j, k, s)		( j == 0							&&	1 <= k		&&	k <= s	)
#define bar2(j, k, s)		( j == s + 1						&&	1 <= k		&&	k <= s	)
#define bar3(j, k, s)		( j == 2 * s + 2					&&	1 <= k		&&	k <= s	)
#define bar4(j, k, s)		( 1 <= j		&&	j <= s			&&	k == 0					)
#define bar5(j, k, s)		( s + 2 <= j	&&	j <= 2 * s + 1	&&	k == 0					)
#define bar6(j, k, s)		( 1 <= j		&&	j <= s			&&	k == s + 1				)
#define bar7(j, k, s)		( s + 2 <= j	&&	j <= 2 * s + 1	&&	k == s + 1				)

int main()
{
	int s;
	string n, err_n("0");
	
	cin >> s;
	cin.ignore(1, ' ');
	getline(cin, n);

	while ( s != 0 || n != err_n )
	{
		int index = n.length();
		
		if ( s <= 0 || s > MAX_S || index > MAX_DIGIT )
		{
			cin >> s;
			cin.ignore(1, ' ');
			getline(cin, n);
			
			continue;
		}
		
		int i, j, k, k2;
		for ( j = 0; j < 2 * s + 3; j++ )
		{
			for ( i = 0; i < index; i++ )
			{
				for ( k = (s + 3) * i; k < (s + 3) * (i + 1) - 1; k++ )
				{
					k2 = k % (s + 3);
					switch( n[i] ) {
					case '1':
						if ( bar6(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '2':
						if ( bar1(j, k2, s) || bar2(j, k2, s) || bar3(j, k2, s) )
							cout << "-";
						else if ( bar5(j, k2, s) || bar6(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '3':
						if ( bar1(j, k2, s) || bar2(j, k2, s) || bar3(j, k2, s) )
							cout << "-";
						else if ( bar6(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '4':
						if ( bar2(j, k2, s) )
							cout << "-";
						else if ( bar4(j, k2, s) || bar6(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;
					case '5':
						if ( bar1(j, k2, s) || bar2(j, k2, s) || bar3(j, k2, s) )
							cout << "-";
						else if ( bar4(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '6':
						if ( bar1(j, k2, s) || bar2(j, k2, s) || bar3(j, k2, s) )
							cout << "-";
						else if ( bar4(j, k2, s) || bar5(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '7':
						if ( bar1(j, k2, s) )
							cout << "-";
						else if ( bar6(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '8':
						if ( bar1(j, k2, s) || bar2(j, k2, s) || bar3(j, k2, s) )
							cout << "-";
						else if ( bar4(j, k2, s) || bar5(j, k2, s) || bar6(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '9':
						if ( bar1(j, k2, s) || bar2(j, k2, s) || bar3(j, k2, s) )
							cout << "-";
						else if ( bar4(j, k2, s) || bar6(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;

					case '0':
						if ( bar1(j, k2, s) || bar3(j, k2, s) )
							cout << "-";
						else if ( bar4(j, k2, s) || bar5(j, k2, s) || bar6(j, k2, s) || bar7(j, k2, s) )
							cout << "|";
						else
							cout << " ";
						break;
					}
				}
				
				if ( i != index - 1 )
					cout << " ";
			}
			cout << endl;
		}
		
		for ( i = 0; i < (s + 3) * index - 1; i++ )
			cout << " ";
		cout << endl;

		int temp_s = s, temp_index = index;
		string temp_n = n;
		
		cin >> s;
		cin.ignore(1, ' ');
		getline(cin, n);
		
	}
	
	return 0;
}


/*	@END_OF_SOURCE_CODE		*/
yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

Its been awhile, but I will comment.

The max digit per the specification is only 8 decimal places. Your code prints more than that.

There may be other issues, such as trailing spaces or error condition handling (though the spec does not mention anything about such issues).

ok, good luck if you have not already solved this one.
-yoshiro (mark) aoki
yoshiro (mark) aoki
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra »

try to print your output in a file.

when i tried to print output for your program in a file it prints nothing. (I use Visual c++ compiler).
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra »

try this input

1 0123456789

your code prints only
Last edited by Debashis Maitra on Mon Dec 04, 2006 6:36 pm, edited 2 times in total.
Akash chhoyar swopno
Dream to touch the sky
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra »

opps i forgot to write output of your code for my input

it prints only only 9
Akash chhoyar swopno
Dream to touch the sky
leocm
New poster
Posts: 22
Joined: Fri Jul 21, 2006 9:44 am
Location: Brasil

Post by leocm »

winkle, the mistake is that you forgot to do (length = len) when (n == 0).
Then, you may pass the wrong value of length to draw_digits.
winkle
New poster
Posts: 3
Joined: Thu Jun 08, 2006 2:56 pm

Thanks!

Post by winkle »

leocm wrote:winkle, the mistake is that you forgot to do (length = len) when (n == 0).
Then, you may pass the wrong value of length to draw_digits.
Nice spotted! I got AC now, thanks alot! :D
Mushfiqur Rahman
Learning poster
Posts: 56
Joined: Tue Jun 13, 2006 5:18 pm
Location: (CSE, SUST) Sylhet, Bangladesh
Contact:

706

Post by Mushfiqur Rahman »

I am getting Presentation Error in LC Display ( 706). I think I handled all types of mistake which can be the cause of P.E.
But I am getting it for everytime.

Can anybody help me?

Here's my code.

Code: Select all

 Removed After AC
Last edited by Mushfiqur Rahman on Sat Jan 13, 2007 8:49 pm, edited 1 time in total.
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra »

try this input

2 1234567890
3 6789012345
0 0
Akash chhoyar swopno
Dream to touch the sky
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra »

Remember :evil:
Dont open a new thread if there is one already. :evil:
Akash chhoyar swopno
Dream to touch the sky
Post Reply

Return to “Volume 7 (700-799)”