-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCCS1.py
More file actions
64 lines (56 loc) · 1.41 KB
/
Copy pathCCCS1.py
File metadata and controls
64 lines (56 loc) · 1.41 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
58
59
60
61
62
63
64
import sys
size = int(sys.stdin.readline())
prevTop = False
prevBottom = False
count = 0
topRow = [int(x) for x in sys.stdin.readline().split()]
bottomRow = [int(x) for x in sys.stdin.readline().split()]
for i in range(size):
# if i == 0:
# if topRow[i] and bottomRow[i]:
# count += 4
# prevTop = True
# prevBottom = True
if i % 2 == 0:
if topRow[i] and bottomRow[i]:
count += 4
if prevTop:
count -= 2
if prevBottom:
count -= 2
prevTop = True
prevBottom = True
elif topRow[i]:
count += 3
if prevTop:
count -= 2
prevTop = True
prevBottom = False
elif bottomRow[i]:
count += 3
if prevBottom:
count -= 2
prevTop = False
prevBottom = True
else:
prevTop = False
prevBottom = False
else:
if topRow[i]:
count += 3
if prevTop:
count -= 2
prevTop = True
else:
prevTop = False
if bottomRow[i]:
count += 3
if prevBottom:
count -= 2
prevBottom = True
else:
prevBottom = False
# print(prevTop)
# print(prevBottom)
# print(count)
print(count)