
# ++++++ to be replaced by tester ++++++
mylog = print
myexactlog = print
"+++++++++++++++++"

def test():
  "--- test function ---"
  param = [
    # example 1
    ["RR.L"]
    # output: "RR.L"
    # EXPLANATION:  The first domino expends no additional force on the second domino.
    ,
    # example 2
    [".L.R...LR..L.."]
    # output: "LL.RR.LLRRLL.."
    ,
  ]
  for i, parameters_set in enumerate(param):
    idx = i
    mylog(0, idx)
    result = f_gold(* parameters_set)
    myexactlog(1, result)


"-----------------"
### pushDominoes 
from collections import deque
from collections import defaultdict
from typing import *
def f_gold(dominoes: str) -> str:
    n = len(dominoes)
    q = deque()
    time = [-1] * n
    force = defaultdict(list)
    for i, f in enumerate(dominoes):
        if f != '.':
            q.append(i)
            time[i] = 0
            force[i].append(f)
    ans = ['.'] * n
    while q:
        i = q.popleft()
        if len(force[i]) == 1:
            ans[i] = f = force[i][0]
            j = i - 1 if f == 'L' else i + 1
            if 0 <= j < n:
                t = time[i]
                if time[j] == -1:
                    q.append(j)
                    time[j] = t + 1
                    force[j].append(f)
                elif time[j] == t + 1:
                    force[j].append(f)
    return ''.join(ans)
"-----------------"
test()

