Page 5 of 19

Posted: Sun Jun 12, 2005 2:34 am
by Mohammad Mahmudur Rahman
You're program doesn't handle multiple test cases. Note that, the first line of the input file will contain the number of test cases. It was not specified in older versions of the problemset. So, if you use previously downloaded problemset, make sure to update it.

488 PE

Posted: Fri Sep 02, 2005 7:48 am
by Roby
Can somebody help to me find what's wrong with my codes below:

Code: Select all

#include <stdio.h>

int main()
{
 int ampl = 0, freq = 0, n = 0;
 int i = 0, j = 0, k = 0, a = 0, b = 0;
 
 scanf( "%d\n\n", &n );
 
 for ( b = 0; b < n; b++ )
 {
    scanf( "%d %d\n\n", &ampl, &freq );
    
    if ( b )
       printf("\n");
    
    for ( i = 0; i < freq; i++ )
    {
       if ( i )
          printf("\n");
       
       for ( j = 1, a = 1; j > 0; j += a )
       {
          for ( k = 0; k < j; k++ )
             printf("%d", j);
          
          a = ( j == ampl ) ? -1 : a;
          
          if ( a < 0 && j == 1 && i == freq - 1 && b == n - 1 );
          else printf("\n");
       }
    }
 }
 
 return 0;
}
Here's the input of my program:

Code: Select all

3

3 2

7 9

9 20
and here's the output of my program:

Code: Select all

1
22
333
22
1

1
22
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
7777777
88888888
999999999
88888888
7777777
666666
55555
4444
333
22
1
Is my algorithm right?

488 Tangle in triangle wave

Posted: Wed Oct 19, 2005 6:41 pm
by InfiniteLOOP
Not Getting ac, where's the problem?


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdlib.h>

int i=0,j=0,k=0,l=0,c=0,a=0,wf=0;

void main()
{
while (scanf("%d",&c)!=EOF)
{
for (l=1;l<=c;l++){
scanf("%d %d",&a,&wf);
for (k=1;k<=wf;k++)
{
for (i=1;i<=a;i++)
{
for (j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}

for (i=a-1;i>=1;i--)
{
for (j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
}
}
}
}

Posted: Thu Nov 10, 2005 1:30 am
by smilitude
Oh dear....
why dont you use indentation??
hmm... its a multiple input problem... if you look back some page there is another thread on 488!

Posted: Sun Dec 04, 2005 3:22 am
by smilitude
i didnt tell you, they have changed the input specification.
there is a line like

<number of inputs>
....<inputs>.....
....<inputs>.....

i stucked on this prob for half a year. I didnt know, they have change the format and the problemset i had was too old for that change

488

Posted: Tue Dec 06, 2005 5:39 pm
by lastlaugh
This is my code, but the status is "Presentation Error".

I have checked it many times, but i still can not understand what mistakes I make.

Could you hlep me?
Thanks very much.

#include <stdio.h>

void outPutALine(int outputNumber)
{
for(int i=0;i<outputNumber;i++)
printf("%d",outputNumber);
printf("\n");
}

void outputASet(int mediumValue,int howManyShouldDo)
{
for(int j=0;j<howManyShouldDo;j++)
{
for(int i=1;i<=(2*mediumValue-1);i++)
{
if(i<=mediumValue)
outPutALine(i);
else
outPutALine(2*mediumValue-i);
}
printf("\n");
}
}

int main()
{
int counter,mediumValue,howManyShouldDo;
scanf("%d",&counter);
for(int i=0;i<counter;i++)
{
scanf(" %d %d",&mediumValue,&howManyShouldDo);
printf("\n");
outputASet(mediumValue,howManyShouldDo);
}
return 0;
}

Posted: Tue Dec 13, 2005 10:12 pm
by Trust Noone
I think you must delete printf("\n"); in main()

Posted: Sat Jan 07, 2006 5:13 am
by Schutzstaffel
Guess what? WA :-?
I've read all the threads concerning this problem and tried many things and still nothing.

Code: Select all

code AC
What am I missing?
Some inputs/outputs would help to clarify :?
Thanks.

Posted: Sun Jan 08, 2006 11:41 am
by Mohammad Mahmudur Rahman
I think the way you're handling the newline charecters, there won't be one at the end of the last line of the last test case. This will lead to WA.

Posted: Sun Jan 08, 2006 2:31 pm
by Schutzstaffel
But I don't have a newline after the last test case, that's the weird part :-?

Input

Code: Select all

3

3
2

5
3

6
4

1

3
2

Code: Select all

1
22
333
22
1

1
22
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
4444
55555
666666
55555
4444
333
22
1

1
22
333
22
1

1
22
333
22
1 /* ends here*/
Is this a valid output?
Thanks for your help.

Posted: Sun Jan 08, 2006 3:26 pm
by chunyi81
Your sample input is not correct.

The input format given in the problem is

<number of test cases>

<input data>

Running your code with a test case and comparing the output with my just ACed code shows that your output does not have a newline at the end as Mohammad Rahman has pointed out.

You should print each line of output with a newline at the end.

However, the judge's test cases does not seem to agree with the sample output format which says that there is no newline after the output of the last test case.
NOTE: There is a blank line after each separate waveform, excluding the last one.
I got a PE without printing newline after the last test case and AC after printing a newline after every triangle wave.

Posted: Sun Jan 08, 2006 5:27 pm
by Schutzstaffel
I'm not sure if I understand what you're saying, I tried to print a newline after each wave including the last one and got WA, then tried without it as I thought it was supposed to be and got also WA

Code: Select all

code AC
If you have

Code: Select all

1

3
3
Should the output be:

Code: Select all

1\n
22\n
333\n
22\n
1\n
\n
1\n
22\n
333\n
22\n
1
Or should it be:

Code: Select all

1\n
22\n
333\n
22\n
1\n
\n
1\n
22\n
333\n
22\n
1\n
Thanks for your help.

Posted: Mon Jan 09, 2006 4:35 am
by chunyi81
The second one

Try this test case:

Input:

Code: Select all

3

3
2

4
3

5
4
Correct output should be:

Code: Select all

1
22
333
22
1

1
22
333
22
1

1
22
333
4444
333
22
1

1
22
333
4444
333
22
1

1
22
333
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

Your code is now printing extra blank lines.

Posted: Mon Jan 09, 2006 5:36 am
by Schutzstaffel
Thanks, I corrected the extra blank line but it still gives WA. Maybe it miss some critical case :o I've tried every possible way (I think) for the newlines.

Code: Select all

code AC
The output for the input you gave is the same as yours but I also tried to make the last line without the \n because I wasn't sure if it had a newline or not but the results were the same.
I really appreciate your help, thanks.

Posted: Mon Jan 09, 2006 2:38 pm
by Emilio
To Schutzstaffel:

This is your modified code, give AC.
Reply when you see this post and I will cut off here.

Code: Select all

CUT