Page 8 of 15

706 WA

Posted: Thu Jun 08, 2006 3:46 pm
by winkle
Any help on why this isn't accepted would be very appreciated:

Code: Select all

Code removed.

706

Posted: Tue Jun 20, 2006 9:39 pm
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;
	
	}
}

Posted: Tue Jun 20, 2006 9:50 pm
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:

Posted: Tue Jun 20, 2006 11:44 pm
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.

Posted: Sat Aug 26, 2006 8:50 pm
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.

706 - WA... Help Me!!

Posted: Mon Aug 28, 2006 8:48 pm
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		*/

Posted: Mon Oct 30, 2006 10:10 pm
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

Posted: Sun Dec 03, 2006 7:41 pm
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).

Posted: Sun Dec 03, 2006 7:49 pm
by Debashis Maitra
try this input

1 0123456789

your code prints only

Posted: Sun Dec 03, 2006 8:02 pm
by Debashis Maitra
opps i forgot to write output of your code for my input

it prints only only 9

Posted: Thu Dec 21, 2006 3:09 am
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.

Thanks!

Posted: Thu Dec 21, 2006 9:59 am
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

706

Posted: Sat Dec 23, 2006 2:25 pm
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

Posted: Sat Dec 23, 2006 7:42 pm
by Debashis Maitra
try this input

2 1234567890
3 6789012345
0 0

Posted: Sat Dec 23, 2006 9:45 pm
by Debashis Maitra
Remember :evil:
Dont open a new thread if there is one already. :evil: