n = int(input()) txt = list(input()) lst = list() for i in range(n): lst.append(0) b = True while b: b = False for i in range(n-1): if txt[i] == 'P' and txt[i + 1] == 'L': txt[i] = 'L' txt[i+1] = 'P' lst[i] += 1 lst[i+1] += 1 b = True for i in range(n): print(str(lst[i]), end=' ')
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | n = int(input()) txt = list(input()) lst = list() for i in range(n): lst.append(0) b = True while b: b = False for i in range(n-1): if txt[i] == 'P' and txt[i + 1] == 'L': txt[i] = 'L' txt[i+1] = 'P' lst[i] += 1 lst[i+1] += 1 b = True for i in range(n): print(str(lst[i]), end=' ') |