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:
        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]
    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"
        
for i in range(n):
    l.append("W")

for i in range(n):
    if i+1 <= n-1:
        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]

    else:
        if(s[i] == "x" and l[i] == "S") or (s[i] == "o" and l[i] == "W") and t[0] == l[i-1]: l = "-1"
        elif (s[i] == "x" and l[i] == "W") or (s[i] == "o" and l[i] == "S") and t[0] != l[i-1]: 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:
def addleave(p):
    for i in range(1, n-1):
        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 check(result):
        return result
    result = addleave("SW")
    if check(result):
        return result
    result = addleave("WS")
    if check(result):
        return result
    result = addleave("WW")
    if check(result):
        return result
    return -1

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