Problem p02954 (python)

Fixed submission:
import math
import sys
sys.setrecursionlimit(100000)

#S     G     S
#RRR..RLL...LRR...

s = list(input())
leng = len(s)
tmp = "R"
s[0] = "S"

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
        tmp = "L"
    else:
        if tmp == "L":
            s[i] = "S"
        tmp = "R"
lis = [0]*(leng)
tmp_s = 0
tmp_g = leng - 1

for i in range(1,leng):
    if s[i] == "G":
        tmp_g = i
    if s[i] == "S" or i == leng-1:
        if i == leng-1:
            i += 1
        if (tmp_g - tmp_s) % 2 == 0:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2)
            lis[tmp_g] = math.floor((i - tmp_s)/2 + 0.5)
        else:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2 + 0.5)
            lis[tmp_g] = math.floor((i - tmp_s)/2)
        tmp_s = i
        continue

    continue

print (*lis)

Buggy submission (verdict: Runtime Error):
import math

#S     G     S
#RRR..RLL...LRR...

s = list(input())
leng = len(s)
tmp = "R"
s[0] = "S"

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
        tmp = "L"
    else:
        if tmp == "L":
            s[i] = "S"
        tmp = "R"

lis = [0]*(leng)
tmp_s = 0

for i in range(1,leng):
    if s[i] == "S" or i == leng-1:
        if i == leng-1:
            i += 1
        if (tmp_g - tmp_s) % 2 == 0:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2)
            lis[tmp_g] = math.floor((i - tmp_s)/2 + 0.5)
        else:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2 + 0.5)
            lis[tmp_g] = math.floor((i - tmp_s)/2)
        tmp_s = i
        continue
    if s[i] == "G":
        tmp_g = i
    continue

print (*lis)

Buggy submission (verdict: Runtime Error):
import math

#S     G     S
#RRR..RLL...LRR...

s = list(input())
leng = len(s)
tmp = "R"
s[0] = "S"

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
        tmp = "L"
    else:
        if tmp == "L":
            s[i] = "S"
        tmp = "R"
print(s)

lis = [0]*(leng)
tmp_s = 0

for i in range(1,leng):
    if s[i] == "S" or i == leng-1:
        if i == leng-1:
            i += 1
        if (tmp_g - tmp_s) % 2 == 0:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2)
            lis[tmp_g] = math.floor((i - tmp_s)/2 + 0.5)
        else:
            lis[tmp_g-1] = math.floor((i - tmp_s)/2 + 0.5)
            lis[tmp_g] = math.floor((i - tmp_s)/2)
        tmp_s = i
        continue
    if s[i] == "G":
        tmp_g = i
    continue

print (*lis)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

s = list(input())
leng = len(s)
tmp = "R"
lis = [0]*(leng)

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
            tmp = "L"
        else:
            tmp = "L"
    else:   #s[i] =="R"
        tmp = "R"

def count(num,locat):
    if s[locat] == "L":
        num += 1
        count(num,locat-1)
    if s[locat] == "R":
        num += 1
        count(num,locat+1)
    if s[locat] == "G":
        if num%2 == 0:
            lis[locat] += 1
        else:
            lis[locat-1] += 1

for i in range(leng):
    count(0,i)

print (*lis)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

s = list(input())
leng = len(s)
tmp = "R"
lis = [0]*(leng)

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
            tmp = "L"
        else:
            tmp = "L"
    else:   #s[i] =="R"
        tmp = "R"

def count(num,locat):
    if s[locat] == "L":
        num += 1
        count(num,locat-1)
    if s[locat] == "R":
        num += 1
        count(num,locat+1)
    if s[locat] == "G":
        if num%2 == 0:
            lis[locat] += 1
        else:
            lis[locat-1] += 1

for i in range(leng):
    count(0,i)

print (*lis)

Buggy submission (verdict: Runtime Error):
s = list(input())
leng = len(s)
tmp = "R"
lis = [0]*(leng)

for i in range(1,leng):
    if s[i] == "L":
        if tmp == "R":
            s[i] = "G"
            tmp = "L"
        else:
            tmp = "L"
    else:   #s[i] =="R"
        tmp = "R"

def count(num,locat):
    if s[locat] == "L":
        num += 1
        count(num,locat-1)
    if s[locat] == "R":
        num += 1
        count(num,locat+1)
    if s[locat] == "G":
        if num%2 == 0:
            lis[locat] += 1
        else:
            lis[locat-1] += 1

for i in range(leng):
    count(0,i)

print (*lis)