-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva10038.cpp
More file actions
58 lines (53 loc) · 1.16 KB
/
Copy pathUva10038.cpp
File metadata and controls
58 lines (53 loc) · 1.16 KB
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
#include <iostream>
#include <math.h>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <sstream>
using namespace std;
vector<string> tokenize(string &str,char delim){
vector<string> vec;
stringstream ss(str);
string temp;
while(getline(ss,temp,delim)){
vec.push_back(temp);
}
return vec;
}
int main()
{
string line;
while(getline(cin,line)){
vector<string> tokens=tokenize(line,' ');
vector<int> ints;
for(int i=0;i<tokens.size();i++){
ints.push_back(atoi(tokens[i].c_str()));
}
int n=ints[0];
vector<int> jolly;
for(int i=1;i<ints.size()-1;i++){
jolly.push_back(abs(ints[i]-ints[i+1]));
}
sort(jolly.begin(),jolly.end());
bool j=true;
for(int i=0;i<jolly.size();i++){
if(jolly[i]!=(i+1)){
j=false;
break;
}
}
if(j){
cout<<"Jolly"<<endl;
}
else{
cout<<"Not jolly"<<endl;
}
}
return 0;
}