-
Notifications
You must be signed in to change notification settings - Fork 1
/
h2_b.py
65 lines (57 loc) · 1.15 KB
/
h2_b.py
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
"""
Определить вид последовательности
"""
CONSTANT, ASCENDING, WEAKLY_ASCENDING, DESCENDING, WEAKLY_DESCENDING, RANDOM = range(1, 7)
answers = (
"CONSTANT",
"ASCENDING",
"WEAKLY ASCENDING",
"DESCENDING",
"WEAKLY DESCENDING",
"RANDOM"
)
STOP_NUM = -2*(10**9)
t = None
prev = None
while True:
cur = int(input())
if cur == STOP_NUM:
break
# define new_type
new_t = None
if prev is not None:
if cur > prev:
new_t = ASCENDING
elif cur < prev:
new_t = DESCENDING
else:
new_t = CONSTANT
prev = cur
# switch seq_type
if not t:
t = new_t
elif t != new_t:
if t == CONSTANT:
if new_t == ASCENDING:
t = WEAKLY_ASCENDING
elif new_t == DESCENDING:
t = WEAKLY_DESCENDING
elif t == ASCENDING:
if new_t == CONSTANT:
t = WEAKLY_ASCENDING
elif new_t == DESCENDING:
t = RANDOM
elif t == WEAKLY_ASCENDING:
if new_t == DESCENDING:
t = RANDOM
elif t == DESCENDING:
if new_t == CONSTANT:
t = WEAKLY_DESCENDING
elif new_t == ASCENDING:
t = RANDOM
elif t == WEAKLY_DESCENDING:
if new_t == ASCENDING:
t = RANDOM
if not t: #len seq < 2
t = CONSTANT
print(answers[t - 1])