Page 25 of 30
Re: WA in Problem E: Jolly Jumpers 10038
Posted: Tue Jan 28, 2014 9:16 pm
by brianfry713
Doesn't match sample I/O.
Don't use system("pause");
Re: WA in Problem E: Jolly Jumpers 10038
Posted: Wed Jan 29, 2014 12:38 am
by m1m6
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
Re: WA in Problem E: Jolly Jumpers 10038
Posted: Thu Jan 30, 2014 12:14 am
by brianfry713
4 1 3 2 3 is Not jolly
Re: WA in Problem E: Jolly Jumpers 10038
Posted: Fri Feb 07, 2014 2:22 pm
by cse dipto
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
Posted: Tue Feb 11, 2014 5:20 pm
by Murlocks
can someone help me with my code?
/removed ac code
thanks
Re: 10038 - Jolly Jumpers
Posted: Tue Feb 11, 2014 5:58 pm
by rloursua
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;
}
Re: 10038 - Jolly Jumpers
Posted: Tue Feb 11, 2014 10:40 pm
by brianfry713
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.
Re: 10038 - Jolly Jumpers
Posted: Tue Feb 11, 2014 11:06 pm
by Murlocks
@ 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
Posted: Wed Feb 12, 2014 10:08 am
by vsha041
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
Posted: Thu Feb 13, 2014 8:39 am
by Murlocks
@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
Re: 10038 - Jolly Jumpers
Posted: Fri Feb 14, 2014 12:30 am
by brianfry713
Murlocks, that is AC code
Re: 10038 - Jolly Jumpers
Posted: Sun Feb 16, 2014 12:10 am
by Murlocks
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
Posted: Fri Feb 28, 2014 9:04 pm
by me33
Please help me finding error...
Getting WA..
here is my code.
If I comment out line 20. Also get WA.
Re: 10038 -Jolly jumper. getting WA
Posted: Sat Mar 01, 2014 12:08 am
by brianfry713
4 1 3 1 2 is Not jolyy
Re: 10038 -Jolly jumper. getting WA
Posted: Sat Mar 01, 2014 9:16 pm
by me33
Thanks brianfray713..
Got AC.