## 10038 - Jolly Jumpers

Moderator: Board moderators

decken kang
New poster
Posts: 4
Joined: Sat Aug 02, 2003 9:23 am

### 10038WA

/* @JUDGE_ID: 10038 C++ */
#include<iostream.h>
#include<math.h>
void main()
{
long count_n,count,i,left,right,n,ab_minus;
while(cin>>n)
{
cin>>left>>right;
ab_minus=fabs(left-right);
count_n=2;
if(ab_minus==1)
{
count=2;
for(i=3;i<=n;i++)
{
left=right;
cin>>right;
count_n++;
ab_minus=fabs(left-right);
if(ab_minus!=count)
goto check;
count++;
}
cout<<"Jolly"<<endl;
}
else if(ab_minus==n-1)
{
count=n-2;
for(i=3;i<=n;i++)
{
left=right;
cin>>right;
count_n++;
ab_minus=fabs(left-right);
if(ab_minus!=count)
goto check;
count--;
}
cout<<"Jolly"<<endl;
}
check:
if(count_n!=n)
{
for(count_n=count_n+1;count_n<=n;count_n++)
cin>>left;
cout<<"Not jolly"<<endl;
}
}
}
/* @END_OF_SOURCE_CODE */

I don't know why I got WA.
Could anyone give "strange test" to me?
In order that I can find out why.
Thank you.

UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:
Reread the problem description. The differences need not be sorted. They just need to be in the range 1 to N-1 and not repeated for a particular line.

decken kang
New poster
Posts: 4
Joined: Sat Aug 02, 2003 9:23 am

### Thanks.

Now I know why I'm wrong.
Thank you.

decken kang
New poster
Posts: 4
Joined: Sat Aug 02, 2003 9:23 am

### Thanks.

Now I know why I'm wrong.
Thank you.

medv
Learning poster
Posts: 85
Joined: Sun Jul 14, 2002 1:17 pm

### 10038 WA - help me!

I don't know why WA!

program p10038;
const
max = 3010;
var
i,temp,n:integer;
m:array[1..max] of integer;
used:array[1..max] of boolean;
flag:boolean;
begin
while not eof do
begin
for i:=1 to n do read(m[i]);
for i:=1 to n do used[i] := False;
flag := True;
for i:=1 to n-1 do
begin
temp := m[i+1] - m[i];
if (temp < 0) then temp := -temp;
if ((temp = 0) or (temp > n - 1)) then
begin
flag := False;
break;
end;
used[temp] := True;
end;
if (not flag) then
begin
writeln('Not jolly'); continue;
end;
flag := True;
for i:=1 to n-1 do
if (not used[i]) then
begin
flag := False;
break;
end;
if (not flag) then writeln('Not jolly')
else writeln('Jolly');
end;
end.

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
Actually it's not WA but a runtime error, which is erroniously reported to Pascal programmers as WA (Judges: I'll keep nagging about this until I get a decent answer!).

The problem is that the input file contains an extra blank line at the end, so the eof function won't sense the end of file, but the read() function will fail. My favourite way to handle this kind of input is:
[pascal]while not eof do begin
if eoln then begin readln; continue; end; //swallow empty line and test eof again
...
end;[/pascal]
Add this and you'll get AC.
One more thing: please use formatting tags when publishing code!

mooseelkdog
New poster
Posts: 18
Joined: Fri Oct 10, 2003 8:46 am
Location: Airway Heights

I don't understand why this isn't working at least insofar as the wrong answer aspect
[cpp]
#include <iostream> // for input and output
#include <vector> // for vectors
#include <list> // for list
#include <cmath> // for abs

using namespace std;

bool jumper(int *, int);
bool linear(int*, int, int);

bool jumper(int *c, int size)
{
bool found = true;
for(int x = 1; x < size; x++)
{
found = linear(c, size, x);
if(found == false)
return found;

} // end for

return found;

} // end jumper() function

bool linear(int* a, int size, int f)
{
for(int x = 0; x < size; x++)
if(a[x] == f)
return true;

return false;

} // end linear() function

int main()
{
int x = -1,
str = 0,
nums = 0,
* diffs,
tempNum;
vector<int> V;
list<int> L;
list<int> L2;

while(cin >> nums != NULL)
{
cin.get();

for(int x = 0; x < nums; x++)
{
cin >> tempNum;
V.push_back(tempNum);
cin.get();

} // end for

if(nums > 0 && nums < 3000)
{
L = list<int>(V.size());
diffs = new int[nums - 1];

if(V.size() > 0)

L2 = L;

for(int x = 0; x < nums - 1; x++)
{
diffs[x] = abs(L2.front());
L2.pop_front();

} // end for

} // end if

if(jumper(diffs, nums - 1) && nums < 3000)
cout << "Jolly\n";
else
cout << "Not jolly\n";

V.clear();
L.clear();
L2.clear();
nums = 0;

} // end while

return 0;

} // end main() function[/cpp][/cpp]

UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:
Each line of input contains an integer n <= 3000 followed by n integers representing the sequence.

mooseelkdog
New poster
Posts: 18
Joined: Fri Oct 10, 2003 8:46 am
Location: Airway Heights

[cpp]#include <iostream> // for input and output
#include <vector> // for vectors
#include <list> // for list
#include <cmath> // for abs

//#define DEBUG

using namespace std;

bool jumper(int *, int);
bool linear(int*, int, int);

bool jumper(int *c, int size)
{
bool found = true;
if(size == 1)
if(c[0] == 1)
return true;
else
return false;
else
{
for(int x = 1; x < size; x++)
{
found = linear(c, size, x);
if(found == false)
return found;

} // end for

} // end else

return found;

} // end jumper() function

bool linear(int* a, int size, int f)
{
for(int x = 0; x < size; x++)
if(a[x] == f)
return true;

return false;

} // end linear() function

int main()
{
int x = -1,
str = 0,
nums = 0,
* diffs,
tempNum;
vector<int> V;
list<int> L;
list<int> L2;

while(cin >> nums != NULL)
{
cin.get();

for(int x = 0; x < nums; x++)
{
cin >> tempNum;
V.push_back(tempNum);
cin.get();

} // end for

#ifdef DEBUG
copy(V.begin(), V.end(), ostream_iterator<int>(cout, " "));
cout << endl;
#endif

if(nums == 1)
cout << "Not jolly\n";

if(nums > 1 && nums <= 3000)
{
L = list<int>(V.size());
diffs = new int[nums - 1];

if(V.size() > 0)

#ifdef DEBUG
copy(L.begin(), L.end(), ostream_iterator<int>(cout, " "));
cout << endl;
#endif

L2 = L;

#ifdef DEBUG
copy(L2.begin(), L2.end(), ostream_iterator<int>(cout, " "));
cout << endl;
#endif

for(int x = 0; x < nums - 1; x++)
{
diffs[x] = abs(L2.front());
L2.pop_front();

} // end for

#ifdef DEBUG
for(int x = 0; x < nums - 1; x++)
cout << diffs[x] << " ";

cout << endl;
#endif

if(jumper(diffs, nums - 1) && nums <= 3000)
cout << "Jolly\n";
else
cout << "Not jolly\n";

} // end if

V.clear();
L.clear();
L2.clear();
nums = 0;

} // end while

return 0;

} // end main() function
[/cpp]
This still yields all right answers (with not much changes) for what I might expect, I look for all possible values in the sequence, according to the range that might be expected for all of the cases (n == 1, n == 2, and n > 2 and n <=3000, this is frustrating as I have pretty much thought of all possibilities, I want to know if there can be more clarification as to the output for a list of 1 number (I assume it is "Not jolly")

UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

mooseelkdog wrote:I want to know if there can be more clarification as to the output for a list of 1 number (I assume it is "Not jolly")
The definition implies that any sequence of a single integer is a jolly jumper.

mooseelkdog
New poster
Posts: 18
Joined: Fri Oct 10, 2003 8:46 am
Location: Airway Heights
Got it to work finally, extended my arrays an extra element and VOILA!! It works, thanks for the hints

Bug!
New poster
Posts: 24
Joined: Thu Oct 30, 2003 10:19 am

### 10038, Jolly jumper Anyone can help me???

Here is my code, Why I got compile error??
I think it works...

Code: Select all

``````code deleted..
``````
Andre
Last edited by Bug! on Sun Feb 29, 2004 6:56 am, edited 1 time in total.

shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA
You have used mem.h, it is not defined by the UVA compiler.

Bug!
New poster
Posts: 24
Joined: Thu Oct 30, 2003 10:19 am

### I got it

Ooopss... I don't know if mem.h can't be used.
I got ac now , thanx for ur help shamim..

Regard..

problem
New poster
Posts: 27
Joined: Mon Nov 10, 2003 12:40 am

### 10038 wa

[c]

#include<iostream.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
void main()
{
unsigned long int n,check=0,l,m,che=0,b,ch=0,t,j;
unsigned long int array[3000]={0};
while(cin>>m)
{
for(l=0;l<m;l++)
{
cin>>array[l];
}
b=abs(array[1])-abs(array[0]);

for(j=1;j<m-1;j++)
{
if(abs(abs(array[j+1])-abs(array[j]))==(b+1)&&ch!=1)
{
check=1;
b=b+1;
continue;

}
if(abs(abs(array[j+1])-abs(array[j]))==(b-1)&&check!=1)
{
ch=1;
b=b-1;
continue;

}
else
{
che=1;
break;
}
}
if((check==1||ch==1)&&che!=1)
{
cout<<"Jolly\n";
check=0;
ch=0;
che=0;
}
else
cout<<"Not Jolly\n";
che=0;
check=0;ch=0;
}
}

At first i store all the data in array.then check data is in assending order
or desending order that means i want to say 4 3 2 1 or 1 2 3 4.if it is
then solution is Jolly jumper else not.sample input output is in below.

input::
--------
4 1 4 2 3
5 1 4 2 -1 6
102 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
100 1 2 4 7 11 16 22 29 37 46 56 67 79 92 106 121 137 154 172 191 211 232 254 277 301 326 352 379 407 436 466 497 529 562 596 631 667 704 742 781 821 862 904 947 991 1036 1082 1129 1177 1226 1276 1327 1379 1432 1486 1541 1597 1654 1712 1771 1831 1892 1954 2017 2081 2146 2212 2279 2347 2416 2486 2557 2629 2702 2776 2851 2927 3004 3082 3161 3241 3322 3404 3487 3571 3656 3742 3829 3917 4006 4096 4187 4279 4372 4466 4561 4657 4754 4852 4951
4 1 4 2 3
5 1 4 2 -1 6
1000 1 2 4 7 11 16 22 29 37 46 56 67 79 92 106 121 137 154 172 191 211 232 254 277 301 326 352 379 407 436 466 497 529 562 596 631 667 704 742 781 821 862 904 947 991 1036 1082 1129 1177 1226 1276 1327 1379 1432 1486 1541 1597 1654 1712 1771 1831 1892 1954 2017 2081 2146 2212 2279 2347 2416 2486 2557 2629 2702 2776 2851 2927 3004 3082 3161 3241 3322 3404 3487 3571 3656 3742 3829 3917 4006 4096 4187 4279 4372 4466 4561 4657 4754 4852 4951 5051 5152 5254 5357 5461 5566 5672 5779 5887 5996 6106 6217 6329 6442 6556 6671 6787 6904 7022 7141 7261 7382 7504 7627 7751 7876 8002 8129 8257 8386 8516 8647 8779 8912 9046 9181 9317 9454 9592 9731 9871 10012 10154 10297 10441 10586 10732 10879 11027 11176 11326 11477 11629 11782 11936 12091 12247 12404 12562 12721 12881 13042 13204 13367 13531 13696 13862 14029 14197 14366 14536 14707 14879 15052 15226 15401 15577 15754 15932 16111 16291 16472 16654 16837 17021 17206 17392 17579 17767 17956 18146 18337 18529 18722 18916 19111 19307 19504 19702 19901 20101 20302 20504 20707 20911 21116 21322 21529 21737 21946 22156 22367 22579 22792 23006 23221 23437 23654 23872 24091 24311 24532 24754 24977 25201 25426 25652 25879 26107 26336 26566 26797 27029 27262 27496 27731 27967 28204 28442 28681 28921 29162 29404 29647 29891 30136 30382 30629 30877 31126 31376 31627 31879 32132 32386 32641 32897 33154 33412 33671 33931 34192 34454 34717 34981 35246 35512 35779 36047 36316 36586 36857 37129 37402 37676 37951 38227 38504 38782 39061 39341 39622 39904 40187 40471 40756 41042 41329 41617 41906 42196 42487 42779 43072 43366 43661 43957 44254 44552 44851 45151 45452 45754 46057 46361 46666 46972 47279 47587 47896 48206 48517 48829 49142 49456 49771 50087 50404 50722 51041 51361 51682 52004 52327 52651 52976 53302 53629 53957 54286 54616 54947 55279 55612 55946 56281 56617 56954 57292 57631 57971 58312 58654 58997 59341 59686 60032 60379 60727 61076 61426 61777 62129 62482 62836 63191 63547 63904 64262 64621 64981 65342 65704 66067 66431 66796 67162 67529 67897 68266 68636 69007 69379 69752 70126 70501 70877 71254 71632 72011 72391 72772 73154 73537 73921 74306 74692 75079 75467 75856 76246 76637 77029 77422 77816 78211 78607 79004 79402 79801 80201 80602 81004 81407 81811 82216 82622 83029 83437 83846 84256 84667 85079 85492 85906 86321 86737 87154 87572 87991 88411 88832 89254 89677 90101 90526 90952 91379 91807 92236 92666 93097 93529 93962 94396 94831 95267 95704 96142 96581 97021 97462 97904 98347 98791 99236 99682 100129 100577 101026 101476 101927 102379 102832 103286 103741 104197 104654 105112 105571 106031 106492 106954 107417 107881 108346 108812 109279 109747 110216 110686 111157 111629 112102 112576 113051 113527 114004 114482 114961 115441 115922 116404 116887 117371 117856 118342 118829 119317 119806 120296 120787 121279 121772 122266 122761 123257 123754 124252 124751 125251 125752 126254 126757 127261 127766 128272 128779 129287 129796 130306 130817 131329 131842 132356 132871 133387 133904 134422 134941 135461 135982 136504 137027 137551 138076 138602 139129 139657 140186 140716 141247 141779 142312 142846 143381 143917 144454 144992 145531 146071 146612 147154 147697 148241 148786 149332 149879 150427 150976 151526 152077 152629 153182 153736 154291 154847 155404 155962 156521 157081 157642 158204 158767 159331 159896 160462 161029 161597 162166 162736 163307 163879 164452 165026 165601 166177 166754 167332 167911 168491 169072 169654 170237 170821 171406 171992 172579 173167 173756 174346 174937 175529 176122 176716 177311 177907 178504 179102 179701 180301 180902 181504 182107 182711 183316 183922 184529 185137 185746 186356 186967 187579 188192 188806 189421 190037 190654 191272 191891 192511 193132 193754 194377 195001 195626 196252 196879 197507 198136 198766 199397 200029 200662 201296 201931 202567 203204 203842 204481 205121 205762 206404 207047 207691 208336 208982 209629 210277 210926 211576 212227 212879 213532 214186 214841 215497 216154 216812 217471 218131 218792 219454 220117 220781 221446 222112 222779 223447 224116 224786 225457 226129 226802 227476 228151 228827 229504 230182 230861 231541 232222 232904 233587 234271 234956 235642 236329 237017 237706 238396 239087 239779 240472 241166 241861 242557 243254 243952 244651 245351 246052 246754 247457 248161 248866 249572 250279 250987 251696 252406 253117 253829 254542 255256 255971 256687 257404 258122 258841 259561 260282 261004 261727 262451 263176 263902 264629 265357 266086 266816 267547 268279 269012 269746 270481 271217 271954 272692 273431 274171 274912 275654 276397 277141 277886 278632 279379 280127 280876 281626 282377 283129 283882 284636 285391 286147 286904 287662 288421 289181 289942 290704 291467 292231 292996 293762 294529 295297 296066 296836 297607 298379 299152 299926 300701 301477 302254 303032 303811 304591 305372 306154 306937 307721 308506 309292 310079 310867 311656 312446 313237 314029 314822 315616 316411 317207 318004 318802 319601 320401 321202 322004 322807 323611 324416 325222 326029 326837 327646 328456 329267 330079 330892 331706 332521 333337 334154 334972 335791 336611 337432 338254 339077 339901 340726 341552 342379 343207 344036 344866 345697 346529 347362 348196 349031 349867 350704 351542 352381 353221 354062 354904 355747 356591 357436 358282 359129 359977 360826 361676 362527 363379 364232 365086 365941 366797 367654 368512 369371 370231 371092 371954 372817 373681 374546 375412 376279 377147 378016 378886 379757 380629 381502 382376 383251 384127 385004 385882 386761 387641 388522 389404 390287 391171 392056 392942 393829 394717 395606 396496 397387 398279 399172 400066 400961 401857 402754 403652 404551 405451 406352 407254 408157 409061 409966 410872 411779 412687 413596 414506 415417 416329 417242 418156 419071 419987 420904 421822 422741 423661 424582 425504 426427 427351 428276 429202 430129 431057 431986 432916 433847 434779 435712 436646 437581 438517 439454 440392 441331 442271 443212 444154 445097 446041 446986 447932 448879 449827 450776 451726 452677 453629 454582 455536 456491 457447 458404 459362 460321 461281 462242 463204 464167 465131 466096 467062 468029 468997 469966 470936 471907 472879 473852 474826 475801 476777 477754 478732 479711 480691 481672 482654 483637 484621 485606 486592 487579 488567 489556 490546 491537 492529 493522 494516 495511 496507 497504 498502 499501
1000 1 2 4 7 11 16 22 29 37 46 56 67 79 92 106 121 137 154 172 191 211 232 254 277 301 326 352 379 407 436 466 497 529 562 596 631 667 704 742 781 821 862 904 947 991 1036 1082 1129 1177 1226 1276 1327 1379 1432 1486 1541 1597 1654 1712 1771 1831 1892 1954 2017 2081 2146 2212 2279 2347 2416 2486 2557 2629 2702 2776 2851 2927 3004 3082 3161 3241 3322 3404 3487 3571 3656 3742 3829 3917 4006 4096 4187 4279 4372 4466 4561 4657 4754 4852 4951 5051 5152 5254 5357 5461 5566 5672 5779 5887 5996 6106 6217 6329 6442 6556 6671 6787 6904 7022 7141 7261 7382 7504 7627 7751 7876 8002 8129 8257 8386 8516 8647 8779 8912 9046 9181 9317 9454 9592 9731 9871 10012 10154 10297 10441 10586 10732 10879 11027 11176 11326 11477 11629 11782 11936 12091 12247 12404 12562 12721 12881 13042 13204 13367 13531 13696 13862 14029 14197 14366 14536 14707 14879 15052 15226 15401 15577 15754 15932 16111 16291 16472 16654 16837 17021 17206 17392 17579 17767 17956 18146 18337 18529 18722 18916 19111 19307 19504 19702 19901 20101 20302 20504 20707 20911 21116 21322 21529 21737 21946 22156 22367 22579 22792 23006 23221 23437 23654 23872 24091 24311 24532 24754 24977 25201 25426 25652 25879 26107 26336 26566 26797 27029 27262 27496 27731 27967 28204 28442 28681 28921 29162 29404 29647 29891 30136 30382 30629 30877 31126 31376 31627 31879 32132 32386 32641 32897 33154 33412 33671 33931 34192 34454 34717 34981 35246 35512 35779 36047 36316 36586 36857 37129 37402 37676 37951 38227 38504 38782 39061 39341 39622 39904 40187 40471 40756 41042 41329 41617 41906 42196 42487 42779 43072 43366 43661 43957 44254 44552 44851 45151 45452 45754 46057 46361 46666 46972 47279 47587 47896 48206 48517 48829 49142 49456 49771 50087 50404 50722 51041 51361 51682 52004 52327 52651 52976 53302 53629 53957 54286 54616 54947 55279 55612 55946 56281 56617 56954 57292 57631 57971 58312 58654 58997 59341 59686 60032 60379 60727 61076 61426 61777 62129 62482 62836 63191 63547 63904 64262 64621 64981 65342 65704 66067 66431 66796 67162 67529 67897 68266 68636 69007 69379 69752 70126 70501 70877 71254 71632 72011 72391 72772 73154 73537 73921 74306 74692 75079 75467 75856 76246 76637 77029 77422 77816 78211 78607 79004 79402 79801 80201 80602 81004 81407 81811 82216 82622 83029 83437 83846 84256 84667 85079 85492 85906 86321 86737 87154 87572 87991 88411 88832 89254 89677 90101 90526 90952 91379 91807 92236 92666 93097 93529 93962 94396 94831 95267 95704 96142 96581 97021 97462 97904 98347 98791 99236 99682 100129 100577 101026 101476 101927 102379 102832 103286 103741 104197 104654 105112 105571 106031 106492 106954 107417 107881 108346 108812 109279 109747 110216 110686 111157 111629 112102 112576 113051 113527 114004 114482 114961 115441 115922 116404 116887 117371 117856 118342 118829 119317 119806 120296 120787 121279 121772 122266 122761 123257 123754 124252 124751 125251 125752 126254 126757 127261 127766 128272 128779 129287 129796 130306 130817 131329 131842 132356 132871 133387 133904 134422 134941 135461 135982 136504 137027 137551 138076 138602 139129 139657 140186 140716 141247 141779 142312 142846 143381 143917 144454 144992 145531 146071 146612 147154 147697 148241 148786 149332 149879 150427 150976 151526 152077 152629 153182 153736 154291 154847 155404 155962 156521 157081 157642 158204 158767 159331 159896 160462 161029 161597 162166 162736 163307 163879 164452 165026 165601 166177 166754 167332 167911 168491 169072 169654 170237 170821 171406 171992 172579 173167 173756 174346 174937 175529 176122 176716 177311 177907 178504 179102 179701 180301 180902 181504 182107 182711 183316 183922 184529 185137 185746 186356 186967 187579 188192 188806 189421 190037 190654 191272 191891 192511 193132 193754 194377 195001 195626 196252 196879 197507 198136 198766 199397 200029 200662 201296 201931 202567 203204 203842 204481 205121 205762 206404 207047 207691 208336 208982 209629 210277 210926 211576 212227 212879 213532 214186 214841 215497 216154 216812 217471 218131 218792 219454 220117 220781 221446 222112 222779 223447 224116 224786 225457 226129 226802 227476 228151 228827 229504 230182 230861 231541 232222 232904 233587 234271 234956 235642 236329 237017 237706 238396 239087 239779 240472 241166 241861 242557 243254 243952 244651 245351 246052 246754 247457 248161 248866 249572 250279 250987 251696 252406 253117 253829 254542 255256 255971 256687 257404 258122 258841 259561 260282 261004 261727 262451 263176 263902 264629 265357 266086 266816 267547 268279 269012 269746 270481 271217 271954 272692 273431 274171 274912 275654 276397 277141 277886 278632 279379 280127 280876 281626 282377 283129 283882 284636 285391 286147 286904 287662 288421 289181 289942 290704 291467 292231 292996 293762 294529 295297 296066 296836 297607 298379 299152 299926 300701 301477 302254 303032 303811 304591 305372 306154 306937 307721 308506 309292 310079 310867 311656 312446 313237 314029 314822 315616 316411 317207 318004 318802 319601 320401 321202 322004 322807 323611 324416 325222 326029 326837 327646 328456 329267 330079 330892 331706 332521 333337 334154 334972 335791 336611 337432 338254 339077 339901 340726 341552 342379 343207 344036 344866 345697 346529 347362 348196 349031 349867 350704 351542 352381 353221 354062 354904 355747 356591 357436 358282 359129 359977 360826 361676 362527 363379 364232 365086 365941 366797 367654 368512 369371 370231 371092 371954 372817 373681 374546 375412 376279 377147 378016 378886 379757 380629 381502 382376 383251 384127 385004 385882 386761 387641 388522 389404 390287 391171 392056 392942 393829 394717 395606 396496 397387 398279 399172 400066 400961 401857 402754 403652 404551 405451 406352 407254 408157 409061 409966 410872 411779 412687 413596 414506 415417 416329 417242 418156 419071 419987 420904 421822 422741 423661 424582 425504 426427 427351 428276 429202 430129 431057 431986 432916 433847 434779 435712 436646 437581 438517 439454 440392 441331 442271 443212 444154 445097 446041 446986 447932 448879 449827 450776 451726 452677 453629 454582 455536 456491 457447 458404 459362 460321 461281 462242 463204 464167 465131 466096 467062 468029 468997 469966 470936 471907 472879 473852 474826 475801 476777 477754 478732 479711 480691 481672 482654 483637 484621 485606 486592 487579 488567 489556 490546 491537 492529 493522 494516 495511 496507 497504 498502 499
4 1 4 2 3
5 1 4 2 -1 6

output::
--------
Jolly
Not jolly
Not jolly
Jolly
Jolly
Not jolly
Jolly
Not jolly
Jolly
Not jolly
[\c]