637 - Booklet Printing

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

Moderator: Board moderators

Post Reply
and
New poster
Posts: 3
Joined: Sat Jan 04, 2003 1:46 am

637 - Booklet Printing

Post by and » Sat Jan 04, 2003 1:57 am

Does anybody notice that even though problem 637 has more than 60% accepted, but only 10% of them is really correct. all 90% have Presentation Error. It means only 6% overall is accepted.
I don't know what's wrong with my program below. It produced exactly the same output as the sample output, but still got PE.
can anybody help ?

[c]void main ( void ){
while (1){
int i, n;
int a, b, c;

scanf ( "%d\n", &n );
if ( !n ) break;

printf ( "Printing order for %d pages:\n", n );
a = (n%4) ? n/4 + 1 : n/4;
b = a * 4;
c = 1;
for ( i = 1; i <= a; i++){
printf ( "Sheet %2d, front: ", i );
if ( b > n )
printf ( "Blank" );
else
printf ( "%d", b );
b--;
printf ( ", %d\n", c );
c++;

if ( (c > n) && (b > n) )
continue;

printf ( "Sheet %2d, back : ", i );
if ( c > n )
printf ( "Blank" );
else
printf ( "%d", c );
c++;
if ( b > n )
printf ( ", Blank\n" );
else
printf ( ", %d\n", b );
b--;
}
}
}[/c]

and
New poster
Posts: 3
Joined: Sat Jan 04, 2003 1:46 am

637:Booklet Printing : P.E.

Post by and » Sat Jan 04, 2003 1:57 am

Does anybody notice that even though problem 637 has more than 60% accepted, but only 10% of them is really correct. all 90% have Presentation Error. It means only 6% overall is accepted.
I don't know what's wrong with my program below. It produced exactly the same output as the sample output, but still got PE.
can anybody help ?

[c]void main ( void ){
while (1){
int i, n;
int a, b, c;

scanf ( "%d\n", &n );
if ( !n ) break;

printf ( "Printing order for %d pages:\n", n );
a = (n%4) ? n/4 + 1 : n/4;
b = a * 4;
c = 1;
for ( i = 1; i <= a; i++){
printf ( "Sheet %2d, front: ", i );
if ( b > n )
printf ( "Blank" );
else
printf ( "%d", b );
b--;
printf ( ", %d\n", c );
c++;

if ( (c > n) && (b > n) )
continue;

printf ( "Sheet %2d, back : ", i );
if ( c > n )
printf ( "Blank" );
else
printf ( "%d", c );
c++;
if ( b > n )
printf ( ", Blank\n" );
else
printf ( ", %d\n", b );
b--;
}
}
}[/c]

and
New poster
Posts: 3
Joined: Sat Jan 04, 2003 1:46 am

correction

Post by and » Sat Jan 04, 2003 2:11 am

Sorry.
My program is [c]printf ( "Sheet %d,...[/c] not [c]printf ( "Sheet %2d,...[/c]
the %2d was my experiment.

Ashis
New poster
Posts: 1
Joined: Wed Oct 01, 2003 11:12 pm
Location: University of Dhaka.

637...why PE??

Post by Ashis » Mon Oct 06, 2003 4:35 pm

Would you plz chq where is the problem in my code that results Presentation Error??? number 637.

Here is the code..
//637...Booklet printing

#include<math.h> //for ceil()
#include<stdio.h>

int main()
{
int a[25][4];

int i,j,count,page_req;
int x;

while( (1==scanf("%d",&page_req))&&page_req)
{
printf("Printing order for %d pages:\n",page_req);
count=1;
x= (int)ceil(page_req/4.0);

for(i=0; i<x; i++)
{
if(count<=page_req) a[1]=count++;
else a[1]=0;
if(count<=page_req) a[2]=count++;
else a[2]=0;
}

for(i=x-1; i>=0; i--)
{
if(count<=page_req) a[3]=count++;
else a[3]=0;
if(count<=page_req) a[0]=count++;
else a[0]=0;
}

for(i=0; i<x; i++)
{
if(a[0]+a[1]!=0)
{
printf("Sheet %d, front:",i+1);
for(j=0; j<2; j++)
{
if(a[i][j]==0)printf(" Blank");
else printf(" %d",a[i][j]);
if(j==0)printf(",");
}
printf("\n");
}
if(a[i][2]+a[i][3]!=0)
{
printf("Sheet %d, back :",i+1);
for(j=2; j<4; j++)
{
if(a[i][j]==0)printf(" Blank");
else printf(" %d",a[i][j]);
if(j==2)printf(",");
}
printf("\n");
}
}
}
return 0;
}

Thank you in Advance
Ashis
sirf_A S H I S

User avatar
Jemerson
Learning poster
Posts: 59
Joined: Mon Feb 02, 2004 11:19 pm
Contact:

637 - Booklet Printing - Need outputs!

Post by Jemerson » Tue May 17, 2005 10:44 pm

Hi guys, ive got no trouble on coding the problem, and my answers seems all to be correct, but i'm getting WA's. I'm gonna post my program output for the following input just to show that i've coded this problem, in fact what I'd like to receive in my email (jemersonfd@gmail.com) is all possible outputs (1 to 100) so that I could compare them with mine to find the bug, or, if any Java programmer decide to help me I can show my code here. Thanx!

Input:

Code: Select all

1 
2
3
4
5
6
7
8
9
10
11
12
99
100
0
Output:

Code: Select all

Printing order for 1 pages:
Sheet 1, front: Blank, 1
Printing order for 2 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Printing order for 3 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 3
Printing order for 4 pages:
Sheet 1, front: 4, 1
Sheet 1, back : 2, 3
Printing order for 5 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 5
Sheet 2, front: 4, 3
Printing order for 6 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Sheet 2, front: 6, 3
Sheet 2, back : 4, 5
Printing order for 7 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 7
Sheet 2, front: 6, 3
Sheet 2, back : 4, 5
Printing order for 8 pages:
Sheet 1, front: 8, 1
Sheet 1, back : 2, 7
Sheet 2, front: 6, 3
Sheet 2, back : 4, 5
Printing order for 9 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 9
Sheet 2, front: 8, 3
Sheet 2, back : 4, 7
Sheet 3, front: 6, 5
Printing order for 10 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Sheet 2, front: 10, 3
Sheet 2, back : 4, 9
Sheet 3, front: 8, 5
Sheet 3, back : 6, 7
Printing order for 11 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 11
Sheet 2, front: 10, 3
Sheet 2, back : 4, 9
Sheet 3, front: 8, 5
Sheet 3, back : 6, 7
Printing order for 12 pages:
Sheet 1, front: 12, 1
Sheet 1, back : 2, 11
Sheet 2, front: 10, 3
Sheet 2, back : 4, 9
Sheet 3, front: 8, 5
Sheet 3, back : 6, 7
Printing order for 99 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, 99
Sheet 2, front: 98, 3
Sheet 2, back : 4, 97
Sheet 3, front: 96, 5
Sheet 3, back : 6, 95
Sheet 4, front: 94, 7
Sheet 4, back : 8, 93
Sheet 5, front: 92, 9
Sheet 5, back : 10, 91
Sheet 6, front: 90, 11
Sheet 6, back : 12, 89
Sheet 7, front: 88, 13
Sheet 7, back : 14, 87
Sheet 8, front: 86, 15
Sheet 8, back : 16, 85
Sheet 9, front: 84, 17
Sheet 9, back : 18, 83
Sheet 10, front: 82, 19
Sheet 10, back : 20, 81
Sheet 11, front: 80, 21
Sheet 11, back : 22, 79
Sheet 12, front: 78, 23
Sheet 12, back : 24, 77
Sheet 13, front: 76, 25
Sheet 13, back : 26, 75
Sheet 14, front: 74, 27
Sheet 14, back : 28, 73
Sheet 15, front: 72, 29
Sheet 15, back : 30, 71
Sheet 16, front: 70, 31
Sheet 16, back : 32, 69
Sheet 17, front: 68, 33
Sheet 17, back : 34, 67
Sheet 18, front: 66, 35
Sheet 18, back : 36, 65
Sheet 19, front: 64, 37
Sheet 19, back : 38, 63
Sheet 20, front: 62, 39
Sheet 20, back : 40, 61
Sheet 21, front: 60, 41
Sheet 21, back : 42, 59
Sheet 22, front: 58, 43
Sheet 22, back : 44, 57
Sheet 23, front: 56, 45
Sheet 23, back : 46, 55
Sheet 24, front: 54, 47
Sheet 24, back : 48, 53
Sheet 25, front: 52, 49
Sheet 25, back : 50, 51
Printing order for 100 pages:
Sheet 1, front: 100, 1
Sheet 1, back : 2, 99
Sheet 2, front: 98, 3
Sheet 2, back : 4, 97
Sheet 3, front: 96, 5
Sheet 3, back : 6, 95
Sheet 4, front: 94, 7
Sheet 4, back : 8, 93
Sheet 5, front: 92, 9
Sheet 5, back : 10, 91
Sheet 6, front: 90, 11
Sheet 6, back : 12, 89
Sheet 7, front: 88, 13
Sheet 7, back : 14, 87
Sheet 8, front: 86, 15
Sheet 8, back : 16, 85
Sheet 9, front: 84, 17
Sheet 9, back : 18, 83
Sheet 10, front: 82, 19
Sheet 10, back : 20, 81
Sheet 11, front: 80, 21
Sheet 11, back : 22, 79
Sheet 12, front: 78, 23
Sheet 12, back : 24, 77
Sheet 13, front: 76, 25
Sheet 13, back : 26, 75
Sheet 14, front: 74, 27
Sheet 14, back : 28, 73
Sheet 15, front: 72, 29
Sheet 15, back : 30, 71
Sheet 16, front: 70, 31
Sheet 16, back : 32, 69
Sheet 17, front: 68, 33
Sheet 17, back : 34, 67
Sheet 18, front: 66, 35
Sheet 18, back : 36, 65
Sheet 19, front: 64, 37
Sheet 19, back : 38, 63
Sheet 20, front: 62, 39
Sheet 20, back : 40, 61
Sheet 21, front: 60, 41
Sheet 21, back : 42, 59
Sheet 22, front: 58, 43
Sheet 22, back : 44, 57
Sheet 23, front: 56, 45
Sheet 23, back : 46, 55
Sheet 24, front: 54, 47
Sheet 24, back : 48, 53
Sheet 25, front: 52, 49
Sheet 25, back : 50, 51
UFCG Brazil - Computer Science graduate student
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!

User avatar
dumb dan
Learning poster
Posts: 67
Joined: Tue Aug 05, 2003 1:02 am

Post by dumb dan » Wed May 18, 2005 9:00 am

I think if you solve this case correctly, you'll likely solve all cases correctly:

input:

Code: Select all

5
0
output:

Code: Select all

Printing order for 5 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Sheet 2, front: Blank, 3
Sheet 2, back : 4, 5

User avatar
Jemerson
Learning poster
Posts: 59
Joined: Mon Feb 02, 2004 11:19 pm
Contact:

Post by Jemerson » Wed May 18, 2005 4:07 pm

Ow man.. , as you can see I hadn't check my output very well :oops:
Thanx for showing my mistake.
UFCG Brazil - Computer Science graduate student
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!

plAnadecU
New poster
Posts: 2
Joined: Tue Mar 07, 2006 12:27 am

Post by plAnadecU » Tue Mar 28, 2006 12:50 am

planadecu@default ~/concurs/acm/637 $ diff in out
1d0
<
15,16c14,16
< Sheet 1, back : 2, 5
< Sheet 2, front: 4, 3
---
> Sheet 1, back : 2, Blank
> Sheet 2, front: Blank, 3
> Sheet 2, back : 4, 5
34,37c34,38
< Sheet 1, back : 2, 9
< Sheet 2, front: 8, 3
< Sheet 2, back : 4, 7
< Sheet 3, front: 6, 5
---
> Sheet 1, back : 2, Blank
> Sheet 2, front: Blank, 3
> Sheet 2, back : 4, 9
> Sheet 3, front: 8, 5
> Sheet 3, back : 6, 7
160c161
< Sheet 25, back : 50, 51
\ No newline at end of file
---
> Sheet 25, back : 50, 51

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 637 - Booklet Printing

Post by uDebug » Tue Jun 03, 2014 12:17 pm

Replying to follow the thread.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

rockson
New poster
Posts: 2
Joined: Sun Aug 17, 2014 10:54 am

637

Post by rockson » Sun Aug 17, 2014 10:59 am

Hi guys what's wrong with my code?

Code: Select all

Thanks :)
I get PE
Last edited by rockson on Mon Aug 18, 2014 3:45 pm, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 637

Post by lighted » Mon Aug 18, 2014 1:50 am

My advice to you -> always copy/paste output format from sample or problem description. :)

Your output

Code: Select all

Sheet 1, back: 2, Blank
Sample output

Code: Select all

Sheet 1, back : 2, Blank
Don't forget to remove your code after getting accepted. 8)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 6 (600-699)”