-
Notifications
You must be signed in to change notification settings - Fork 0
/
p10038.cpp
34 lines (32 loc) · 844 Bytes
/
p10038.cpp
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
#include <iostream>
#include <vector>
bool is_jolly(std::vector<int> input) {
std::vector<bool> is_used(input.size() - 1, false);
for (int i = 1; i < input.size(); i++) {
auto difference = abs(input[i - 1] - input[i]);
if (difference >= input.size() || difference == 0)
return false;
if (is_used[difference - 1])
return false;
is_used[difference - 1] = true;
}
return true;
}
int main() {
int n = 0;
int temp = 0;
std::vector<int> input;
while (std::cin >> n) {
input.clear();
for (int i = 0; i < n; i++) {
std::cin >> temp;
input.push_back(temp);
}
if (is_jolly(input)) {
std::cout << "Jolly\n";
} else {
std::cout << "Not jolly\n";
}
}
return 0;
}