10038 - Jolly Jumpers

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

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA in Problem E: Jolly Jumpers 10038

Post by brianfry713 » Tue Jan 28, 2014 9:16 pm

Doesn't match sample I/O.
Don't use system("pause");
Check input and AC output for thousands of problems on uDebug!

m1m6
New poster
Posts: 2
Joined: Mon Jan 27, 2014 12:44 am

Re: WA in Problem E: Jolly Jumpers 10038

Post by m1m6 » Wed Jan 29, 2014 12:38 am

Doesn't match sample I/O.
how !!

try these....
4 1 4 2 3
5 1 4 2 -1 6
5 3 2 3 2 3
4 1 4 2 3
5 1 4 2 -1 6
1 1
2 1 2
4 5 5 5 5
5 10 8 6 4 2
4 1 4 3 1
4 3 1 5 2


output :

Jolly
Not jolly
Not jolly
Jolly
Not jolly
Jolly
Jolly
Not jolly
Not jolly
Jolly
Not jolly

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA in Problem E: Jolly Jumpers 10038

Post by brianfry713 » Thu Jan 30, 2014 12:14 am

4 1 3 2 3 is Not jolly
Check input and AC output for thousands of problems on uDebug!

cse dipto
New poster
Posts: 22
Joined: Tue Oct 29, 2013 6:46 pm

Re: WA in Problem E: Jolly Jumpers 10038

Post by cse dipto » Fri Feb 07, 2014 2:22 pm


8 4 2 5 9 8 3 1 -2
Not jolly
2 1 -1
Jolly
7 1 2 3 4 5 6 -3
Not jolly
5 100 200 9 101 1023
Not jolly
4 1 2 4 1
Jolly
0
Not jolly

Murlocks
New poster
Posts: 4
Joined: Tue Feb 11, 2014 5:18 pm

Re: 10038 - Jolly Jumpers

Post by Murlocks » Tue Feb 11, 2014 5:20 pm

can someone help me with my code?

/removed ac code

thanks
Last edited by Murlocks on Sun Feb 16, 2014 12:11 am, edited 2 times in total.

rloursua
New poster
Posts: 4
Joined: Tue Feb 11, 2014 5:52 pm

Re: 10038 - Jolly Jumpers

Post by rloursua » Tue Feb 11, 2014 5:58 pm

Could somebody help me with my code? I keep Getting WA :(

Code: Select all

#include <iostream>
using namespace std;

int ls(int *arr, int s, int q)
{
	int i=0;
	for(i=0;i<s;i++)
	{
		if(arr[i]==q)
			return i;
	}
	return -1;
}

int main()
{
	int x,i;
	int num[3005];
	int copy[3005];
	while(cin.good())
	{
		i=0;x=0;
		cin >> x;
		for(i=0;i<x-1;i++)
		{
			cin >> num[i];
			copy[i]=i+1;
		}
		cin>>num[i];
		
		int cond = 1;
		if(x==1)
			cout << "Jolly" << endl;
		else
		{
			for(i=0;i<x-1;i++)
			{	
				int diff = abs(num[i]-num[i+1]);
				int k = ls(copy,x,diff);
				
				if(k==-1)
				{
					cond=0;break;
				}
				else
				{
					copy[k]=0;
				}
			
			}	
			for(i=0;i<x-1;i++)
			{
				if(copy[i]!=0)
					{cond=0; break;}
			}
			if(cond)
				cout << "Jolly" << endl;
			else
				cout << "Not jolly" << endl;
		}
	}
	return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10038 - Jolly Jumpers

Post by brianfry713 » Tue Feb 11, 2014 10:40 pm

Murlocks, don't use "stdafx.h"

rloursua, don't use while(cin.good()), there will be a newline char at the end of the last line.
Check input and AC output for thousands of problems on uDebug!

Murlocks
New poster
Posts: 4
Joined: Tue Feb 11, 2014 5:18 pm

Re: 10038 - Jolly Jumpers

Post by Murlocks » Tue Feb 11, 2014 11:06 pm

@ brian, yeah sorry I didn't mean to include that, when I send the code in to UVA I don't include that header. But even still, I get a wrong answer, are there any other errors in my code? Thanks

vsha041
New poster
Posts: 35
Joined: Wed Feb 12, 2014 10:04 am

Re: 10038 - Jolly Jumpers

Post by vsha041 » Wed Feb 12, 2014 10:08 am

Just remember that for n <= 1 the answer is Jolly. And for n >=2 you do your normal program flow to find the answer.

Murlocks
New poster
Posts: 4
Joined: Tue Feb 11, 2014 5:18 pm

Re: 10038 - Jolly Jumpers

Post by Murlocks » Thu Feb 13, 2014 8:39 am

@brian, not sure if that was directed towards me, but I didn't use while(cin.good()) in my code, I don't think getline works the same way? Or perhaps it does? Not sure

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10038 - Jolly Jumpers

Post by brianfry713 » Fri Feb 14, 2014 12:30 am

Murlocks, that is AC code
Check input and AC output for thousands of problems on uDebug!

Murlocks
New poster
Posts: 4
Joined: Tue Feb 11, 2014 5:18 pm

Re: 10038 - Jolly Jumpers

Post by Murlocks » Sun Feb 16, 2014 12:10 am

yeah it just worked now.. I don't understand why it didn't work before, I made no changes O.o

me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

10038 -Jolly jumper. getting WA

Post by me33 » Fri Feb 28, 2014 9:04 pm

Please help me finding error...

Getting WA..

here is my code.
If I comment out line 20. Also get WA.

Code: Select all

Removed after AC
Last edited by me33 on Sat Mar 01, 2014 9:17 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10038 -Jolly jumper. getting WA

Post by brianfry713 » Sat Mar 01, 2014 12:08 am

4 1 3 1 2 is Not jolyy
Check input and AC output for thousands of problems on uDebug!

me33
New poster
Posts: 16
Joined: Wed Feb 19, 2014 10:08 pm

Re: 10038 -Jolly jumper. getting WA

Post by me33 » Sat Mar 01, 2014 9:16 pm

Thanks brianfray713..

Got AC.

Post Reply

Return to “Volume 100 (10000-10099)”