Page 2 of 30

Posted: Sun Apr 06, 2003 12:28 pm
by Hisoka
I think your description is wrong.

Code: Select all

input 
5 1 4 1 3 2

output
not jolly
I hope this will be help you. :wink:

Another WA without knowing the reason

Posted: Tue Apr 08, 2003 1:57 pm
by timrau
[c]#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int n;
int last,now;
int ta;
int ansed;
while(scanf("%d",&n)==1)
{
ansed=0;
scanf("%d",&last);
for(ta=2;ta<=n;ta++)
{
scanf("%d",&now);
if((!ansed) && ((abs(now-last)>=n) || now==last))
{
printf("Not jolly\n");
ansed=1;
}
last=now;
}
if(!ansed)
printf("Jolly\n");
}
return(0);
}[/c]
I don't understand why this got a WA.

Posted: Tue Apr 08, 2003 2:31 pm
by Hisoka
Hey, why you not check your program with my sample I/O before you post your code? your program have same mistake with Nick program (cannot pass with my sample IO). :x

-HISOKA-

Posted: Sat Apr 12, 2003 3:35 am
by timrau
Hisoka wrote:Hey, why you not check your program with my sample I/O before you post your code? your program have same mistake with Nick program (cannot pass with my sample IO). :x

-HISOKA-
But...But I don't understand why your sample input is not "Jolly"? :cry:

Posted: Sat Apr 12, 2003 6:32 am
by Eric
The problem states that the differneces must map all the value between N-1 to 1.
But in the sample I/O from Hisoka, the differences are 3,3,2,1
which is different from the requirement of 4,3,2,1
So, it is not jolly. Do you get it? :wink:

Thanks for your help

Posted: Tue Apr 15, 2003 3:04 pm
by Nick
Especially to Eric, thanks!!
I thought that as long as the numbers are between 1 and N-1, the sequence is Jolly, so there can be more than one same numbers.
But i was wrong, though I haven't try to fixed my code

Posted: Sat May 03, 2003 4:39 am
by JiaYun
Input:

Code: Select all

4 1 4 2 3
5 1 4 2 -1 6
Your program will give 3 results:

Code: Select all

Jolly
Not jolly
Not jolly
Perhaps, this problem should be fixed first. :oops:

10038 W.A

Posted: Sun May 25, 2003 3:04 pm
by lendlice
i got W.A
anyone can help me
thanks
[cpp]//10038
#include<stdio.h>
#include<math.h>
main()
{
int in[5000],many=0,i=0,count=0,ans;
while(scanf("%d",&many)==1)
{
for(i=0;i<many;i++)
scanf("%d",&in);
for(i=0;i<many-1;i++)
{
ans=fabs(in-in[i+1]);
if(ans>=1&&ans<many)
count++;
else
break;
}
if(count==many-1)
printf("Jolly\n");
else
printf("Not jolly\n");
count=0;
}
}[/cpp]

Posted: Sun Jun 01, 2003 5:40 am
by Amir Aavani
hi lendlice

the problem say that the difference should take on all the values 1 through n-1.
but your program doesn't consider it.

for examle for the following input your program say Jolly in case it is n't really Jolly

3 1 2 3

Posted: Sun Jun 22, 2003 4:43 am
by Taneem
Lendlice,

The problem states..."differences between successive elements take on
ALL possible values between 1 thru N-1. For example,

1 4 2 3 is "Jolly" because it takes the differences {3,2,1} which satisfies all the values between N-1 (=3) through 1.

Therefore, you must keep track of individual differences (hint: an array indexed with the differences will be a way to go).

Hope this helps :)

Re: 10038 W.A

Posted: Sun Jun 22, 2003 12:27 pm
by zsepi
lendlice,
I think you might have misunderstood the problem, bacause you only check if the difference between two consecutive numbers is bigger than 0 and less than many. Just to check out this input:

Code: Select all

5 3 2 3 2 3
and obviously, it's not good.
you need to check if all the differences take on all the values 1 through many-1

HELP NEEDED

Posted: Mon Jun 30, 2003 4:17 am
by powerboy
what is wrong with my program???
Anyone help me
[cpp]#include <iostream.h>
#include <stdlib.h>

int main()
{
int first = 0;
int second = 0;
int num;
bool * array;
bool flag = true;

while (cin >> num)
{
if (num > 1)
{
array = new bool[num];
int i;
for (i = 1; i <= num; i++)
{
array = false;
}

cin >> second;

for (i = 2; i <= num; i++)
{
first = second;
cin >> second;
if (abs(first - second) < num)
{
array[abs(first - second)] = true;
}
}

for (i = 1; i < num; i++)
{
if (!array)
{
cout << "Not jolly" << endl;
flag = false;
break;
}
}

if (flag)
cout << "Jolly" << endl;

flag = true;
}
else if (num == 1)
{
cin >> num;
}
}
return 0;
}[/cpp]

10038 WA

Posted: Fri Jul 11, 2003 6:53 am
by if11026
Could anybody tell me what's wrong with my code ?

[c]
/* @JUDGE_ID: 10038 C */

#include <stdio.h>
#include <stdlib.h>
#define true 1
#define false 0
#define boolean unsigned int

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


int main()
{
boolean Jolly;
int jumdata,i;
int j,diff;
long data[3001];
long kurang[3000];
#ifndef ONLINE_JUDGE
close (0); open ("jump6.txt", O_RDONLY);

close (1); open ("jumpout6.txt", O_WRONLY | O_CREAT, 0600);
#endif


while (scanf("%d",&jumdata)== 1)
{
for (i = 0; i <= 3000; i++)
{
kurang = 0;
}
if ( jumdata == 1)
{
printf("Jolly\n");
}
else
{
for (i = 0; i< jumdata; i++)
{
scanf("%ld",&data);
}
Jolly = true;
i = 1;
while ((i < jumdata) && (Jolly))
{
diff = abs(data - data);
if ((diff > 0) && (diff < jumdata))
{
if (kurang[diff] == 1)
{
Jolly = false;
}
else
{
kurang[diff] = 1;
}
}
else
{
Jolly = false;
}
i++;

}
if (Jolly)
{
printf("Jolly\n");
}
else
{
printf("Not Jolly\n");
}
}
}
return 0;
}
[/c]

10038WA

Posted: Sat Jul 19, 2003 7:12 am
by turtleking

Code: Select all

#include <stdio.h>


int abs(int value)
{
	if (value>=0)
	{return value;}
	else
	{return -value;}
}


void jolly(int series[4000],int inputnum)
{
	int i,j;
	int jolly=0;
	int abs_value;
	int temp[4000];
	for(i=0;i<(inputnum-1);i++)
	{
		abs_value = abs(series[i]-series[i+1]);
		if ((abs_value<=(inputnum-1) )&&(abs_value>=0))
		{
			for(j=1;j<inputnum;j++)
			{
				if (abs_value == j)
				{temp[j]=1;}
			}

		}
	}
	for(i=1;i<inputnum;i++)
	{
		if (temp[i]!=1)
		{
			jolly=1;
		}

	}
	if (!jolly)
	{
		printf("Jolly\n");
	}
	else
	{
		printf("Not jolly\n");
	}
}



void main(void)
{
	int inputnum,i;
	int series[4000];
	while(scanf("%d",&inputnum)==1)
	{
	 for(i=0;i<inputnum;i++)
	 {
		 scanf("%d",&series[i]);
	 }
	 
		 jolly(series,inputnum);
	 
	 
	}
 
}
can anyone tell me what's wrong with my code?[/code]

Posted: Sat Jul 26, 2003 10:32 am
by Joseph Kurniawan
You should make all the integers stored in array temp zero after you use the function jolly.
[c]for(j=1;j<inputnum;j++)
{
if (abs_value == j)
{temp[j]=1;}
}
[/c]

This will make the integer in temp[j] one.