10038 - Jolly Jumpers
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: WA in Problem E: Jolly Jumpers 10038
Doesn't match sample I/O.
Don't use system("pause");
Don't use system("pause");
Check input and AC output for thousands of problems on uDebug!
Re: WA in Problem E: Jolly Jumpers 10038
how !!Doesn't match sample I/O.
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
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: WA in Problem E: Jolly Jumpers 10038
4 1 3 2 3 is Not jolly
Check input and AC output for thousands of problems on uDebug!
Re: WA in Problem E: Jolly Jumpers 10038
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
Re: 10038 - Jolly Jumpers
can someone help me with my code?
/removed ac code
thanks
/removed ac code
thanks
Last edited by Murlocks on Sun Feb 16, 2014 12:11 am, edited 2 times in total.
Re: 10038 - Jolly Jumpers
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10038 - Jolly Jumpers
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.
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!
Re: 10038 - Jolly Jumpers
@ 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
Re: 10038 - Jolly Jumpers
Just remember that for n <= 1 the answer is Jolly. And for n >=2 you do your normal program flow to find the answer.
Re: 10038 - Jolly Jumpers
@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
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10038 - Jolly Jumpers
Murlocks, that is AC code
Check input and AC output for thousands of problems on uDebug!
Re: 10038 - Jolly Jumpers
yeah it just worked now.. I don't understand why it didn't work before, I made no changes O.o
10038 -Jolly jumper. getting WA
Please help me finding error...
Getting WA..
here is my code.
If I comment out line 20. Also get WA.
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.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10038 -Jolly jumper. getting WA
4 1 3 1 2 is Not jolyy
Check input and AC output for thousands of problems on uDebug!
Re: 10038 -Jolly jumper. getting WA
Thanks brianfray713..
Got AC.
Got AC.