Problem:
Snuke, who loves animals, built a zoo.  There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.  There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.  Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species.  More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise.  Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3

n = int(input())
s = input()
t = []
l = []
for i in range(n):
    t.append("S")

for i in range(n):
    if i+1 <= n-1 and i != 0:
        if (s[i] == "x" and t[i] == "S") or (s[i] == "o" and t[i] == "W"):
            if t[i-1] == "S":
                t[i+1] = "W"

            else:
                t[i+1] = "S"

        else:
            t[i+1] = t[i]
    elif i == 0:
        pass
    else:
        if ((s[i] == "x" and t[i] == "S") or (s[i] == "o" and t[i] == "W")) and t[0] == t[i-1]: t = "-1"
        elif ((s[i] == "x" and t[i] == "W") or (s[i] == "o" and t[i] == "S")) and t[0] != t[i-1]: t = "-1"
        elif ((s[0] == "o" and t[0] == "S") or (s[0] == "x" and t[0] == "W")) and t[1] != t[i]: t = "-1"
        elif ((s[0] == "o" and t[0] == "W") or (s[0] == "x" and t[0] == "S")) and t[1] == t[i]: t = "-1"
for i in range(n):
    l.append("W")

for i in range(n):
    if i+1 <= n-1 and i != 0:
        if (s[i] == "x" and l[i] == "S") or (s[i] == "o" and l[i] == "W"):
            if l[i-1] == "S":
                l[i+1] = "W"

            else:
                l[i+1] = "S"

        else:
            l[i+1] = l[i]
            
    elif i == 0:
        pass
    else:
        if(s[i] == "x" and l[i] == "S") or (s[i] == "o" and l[i] == "W") and l[0] == l[i-1]: l = "-1"
        elif (s[i] == "x" and l[i] == "W") or (s[i] == "o" and l[i] == "S") and l[0] != l[i-1]: l = "-1"
        elif ((s[0] == "o" and l[0] == "S") or (s[0] == "x" and l[0] == "W")) and l[1] != l[i]: l = "-1"
        elif ((s[0] == "o" and l[0] == "W") or (s[0] == "x" and l[0] == "S")) and l[1] == l[i]: l = "-1"
if t != "-1" and l == "-1":
    for i in t:
        print(i,end ="")

elif t == "-1" and l != "-1":
    for i in l:
        print(i,end ="")

elif t == l:print("-1")
else:
    for i in t:
        print(i,end ="")


Fixed, accepted submission:
n = int(input())
s = input()

def addleave(p):
    for i in range(1,n):
        if s[i]=="o":
            if p[i]=="S":
                p += "S" if p[i-1]=="S" else "W"
            else:
                p += "W" if p[i-1]=="S" else "S"
        else:
            if p[i]=="S":
                p += "W" if p[i-1]=="S" else "S"
            else:
                p += "S" if p[i-1]=="S" else "W"
    return p
def solve():
    result = addleave("SS")
    if result[-1] == result[0]:
        if check(result):
            return result[:-1]
    result = addleave("SW")
    if result[-1] == result[0]:
        if check(result):
            return result[:-1]
    result = addleave("WS")
    if result[-1] == result[0]:
        if check(result):
            return result[:-1]

    result = addleave("WW")
    if result[-1] == result[0]:
        if check(result):
            return result[:-1]
    return -1

def check(res):
    res = res[:-1] + res[:-1] + res[:-1]
    flag = True
    for i in range(n):
        if res[n + i - 1] == res[n + i + 1] and res[n + i]=="S" and s[i]=="o":
            pass
        elif res[n + i - 1] != res[n + i + 1] and res[n + i]=="S" and s[i]=="x":
            pass
        elif res[n + i - 1] == res[n + i + 1] and res[n + i]=="W" and s[i]=="x":
            pass
        elif res[n + i - 1] != res[n + i + 1] and res[n + i]=="W" and s[i]=="o":
            pass
        else:
            flag = False
    return flag
print(solve())