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`.

Submission attempts (in order):
import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)


for t in L:  
    for i in range(1,l+1):
        if (s[(i+l)%l]=="x") ^ (t[-1] == "W"):
            if t[-2]=="S":
                t+= "W"
            else:
                t += "S"
            
        else:
            t += t[-2]
    if t[0:2]==t[-2:]:
        print(t)
        sys.exit()
print(-1)
    


import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)



for t in L:
  　tmp = t###
    for i in range(l):
        if (s[i]=="x") ^ (tmp[-1] == "W"):
            if tmp[-2]=="S":
                tmp+= "W"
            else:
                tmp += "S"
            
        else:
            tmp += tmp[-2]
    if tmp[:2]==tmp[-2:]:
        print(tmp)
        sys.exit()
print(-1)
    


import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)



for t in L:  
    for i in range(l):
        if (s[i]=="x") ^ (t[-1] == "W"):
            if t[-2]=="S":
                t+= "W"
            else:
                t += "S"
            
        else:
            t += t[-2]
    if t[:2]==t[-2:]:
        print(t)
        sys.exit()
print(-1)
    


import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)

for t in L:  
    for i in range(1,l+1):
        if (s[(i+l)%l]=="x") ^ (t[-1] == "W"):
            t += t[-2]
        else:
            if t[-2]=="S":
                t+= "W"
            else:
                t += "S"
    if t[0:2]==t[-2:]:
        print(t)
        sys.exit()
print(-1)
    



import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)



for t in L:
    tmp = t###
    for i in range(l):
        if (s[i]=="x") ^ (tmp[-1] == "W"):
            if tmp[-2]=="S":
                tmp+= "W"
            else:
                tmp += "S"
            
        else:
            tmp += tmp[-2]
    if tmp[:2]==tmp[-2:]:
        print(tmp[1:-1])###
        sys.exit()
print(-1)
    


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted