-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD.py
More file actions
35 lines (28 loc) · 650 Bytes
/
D.py
File metadata and controls
35 lines (28 loc) · 650 Bytes
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
import math
s = list(input())
count = [0]*len(s)
lc = 0
rc = 0
for i in range(len(s)-1):
if s[i] == 'R':
rc += 1
if s[i+1] == 'L':
count[i] += int(math.ceil(rc/2))
count[i+1] += int(math.floor(rc/2))
rc = 0
elif s[i] == 'L':
continue
count = count[::-1]
s = s[::-1]
lc = 0
rc = 0
for i in range(len(s)-1):
if s[i] == 'L':
lc += 1
if s[i+1] == 'R' and rc == 0:
count[i] += int(math.ceil(lc/2))
count[i+1] += int(math.floor(lc/2))
lc = 0
elif s[i] == 'R':
continue
print(' '.join(list(map(str, count[::-1]))))