Problem:


Score : 500 points

Problem Statement

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.

Constraints

3 ≤ N ≤ 10^{5}

s is a string of length N consisting of o and x.

Input

The input is given from Standard Input in the following format:

N
s

Output

If there does not exist an valid assignment that is consistent with s, print -1.
Otherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s.

t is a string of length N consisting of S and W.

If t_i is S, it indicates that the animal numbered i is a sheep. If t_i is W, it indicates that the animal numbered i is a wolf.

Sample Input 1

6
ooxoox

Sample Output 1

SSSWWS

For example, if the animals numbered 1, 2, 3, 4, 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.

Let us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x. If the neiboring animals are of different species, a sheep answers x and a wolf answers o.

Sample Input 2

3
oox

Sample Output 2

-1

Print -1 if there is no valid assignment of species.

Sample Input 3

10
oxooxoxoox

Sample Output 3

SSWWSSSWWS



Sample input:
6
ooxoox


Sample output:
SSSWWS

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
s = input().rstrip()

ans = ["?"] * N

for i in range(N):
    if i == 0:
        if s[i] == "o":
            ans[i] = "s"
            ans[i + 1] = "s"
            ans[i - 1] = "s"
        else:
            ans[i] = "s"
        continue
    
    if i == N - 1:
        if s[i] == "o":
            if ans[i] == "s":
                if not (ans[i - 1] == "s" and ans[0] == "s"):
                    print(-1)
                    sys.exit()
            else:
                if ans[i - 1] == "w" and ans[0] == "w":
                    print(-1)
                    sys.exit()
        else:
            if ans[i] == "w":
                if not (ans[i - 1] == "w" and ans[0] == "w"):
                    print(-1)
                    sys.exit()
            else:
                if ans[i - 1] == "s" and ans[0] == "s":
                    print(-1)
                    sys.exit()
        break
    
    if s[i] == "o":
        if ans[i] == "s":
            ans[i + 1] = "s"
            if ans[i - 1] != "s":
                print(-1)
                sys.exit()
        else:
            if ans[i - 1] == "w":
                ans[i + 1] = "s"
            else:
                ans[i + 1] = "w"
    else:
        if ans[i] == "w":
            ans[i + 1] = "w"
            if ans[i - 1] != "w":
                print(-1)
                sys.exit()
        else:
            if ans[i - 1] == "s":
                ans[i + 1] = "w"
            else:
                ans[i + 1] = "s"

print("".join(ans).upper())

Submission status: Wrong Answer

Solution code:
n = int(input())
s  = input()
a1 = [1,1]
a2 = [1,-1]
a3 = [-1,1]
a4 = [-1,-1]
f= False

for a in [a1,a2,a3,a4]:
    for i in range(1,n):
        if s[i] =="o":
            if a[i] == 1:
                a.append(a[i-1])
            else:
                a.append(-1*a[i-1])
        elif s[i] =="x" :
            if a[i] ==1:
                a.append(-1*a[i-1])
            else:
                a.append(a[i-1])

    if a[n] == a[0]:
        f = True
        break

if f:
    ans = []
    for i in range(n):
        if a[i]==1:
            ans.append("S")
        else:
            ans.append("W")
    print("".join(ans))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    s = list(input())

    def check(p):
        for i in range(1, N):
            if s[i]=='o' and p[i]=='S':
                p += p[i-1]
            elif s[i]=='o' and p[i]=='W':
                if p[i-1]=='S':
                    p += 'W'
                else:
                    p += 'S'
            elif s[i]=='x' and p[i]=='S':
                if p[i-1]=='S':
                    p += 'W'
                else:
                    p += 'S'
            else:
                p += p[i-1]
        if p[0]==p[N]:
            print(p[:N])
            exit()

    for i in ['SS', 'SW', 'WS', 'WW']:
        check(i)
    print(-1)
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    s = list(input())

    def check(p):
        for i in range(1, N):
            if s[i]=='o' and p[i]=='S':
                p += p[i-1]
            elif s[i]=='o' and p[i]=='W':
                if p[i-1]=='S':
                    p += 'W'
                else:
                    p += 'S'
            elif s[i]=='x' and p[i]=='S':
                if p[i-1]=='S':
                    p += 'W'
                else:
                    p += 'S'
            if s[i]=='x' and p[i]=='W':
                p += p[i-1]
        if p[0]==p[N]:
            print(p[:N])
            exit()

    for i in ['SS', 'SW', 'WS', 'WW']:
        check(i)
    print(-1)
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input().strip()


def check(a, b):
    v = [0]*N
    v[0] = a
    v[1] = b
    for i in range(1, N-1):
        if s[i] == 'o':
            if v[i]:
                v[i+1] = v[i-1]
            else:
                v[i+1] = not v[i-1]
        else:
            if v[i]:
                v[i+1] = not v[i-1]
            else:
                v[i+1] = v[i-1]

    if s[N-1] == 'o':
        if v[N-1] == (v[N-2] == v[0]):
            return v
        else:
            return None
    else:
        if v[N-1] == (v[N-2] != v[0]):
            return v
        else:
            return None


p = [
    [True, True],
    [False, False],
    [True, False],
    [False, True]
]
ans = "-1"
for a, b in p:
    l = check(a, b)
    if l != None:
        ans = "".join(["S" if v else "W" for v in l])
        break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input().strip()


def check(a, b):
    v = [0]*N
    v[0] = a
    v[1] = b
    for i in range(1, N-1):
        if s[i] == 'o':
            if v[i]:
                v[i+1] = v[i-1]
            else:
                v[i+1] = not v[i-1]
        else:
            if v[i]:
                v[i+1] = not v[i-1]
            else:
                v[i+1] = v[i-1]

    if s[N-1] == 'o':
        if v[N-1] == (v[N-2] == v[0]):
            return v
        else:
            return None
    else:
        if v[N-1] != (v[N-2] == v[0]):
            return v
        else:
            return None


p = [
    [True, True],
    [False, False],
    [True, False],
    [False, True]
]
ans = "-1"
for a, b in p:
    l = check(a, b)
    if l != None:
        ans = "".join(["S" if v else "W" for v in l])
        break
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product

def next_sw(ox, sw, prev_sw):
    if (ox == 'o' and sw == 'S') or (ox == 'x' and sw == 'W'):
        return prev_sw 
    else:
        return 'W' if prev_sw =='S' else 'S'

N = int(input())
S = input()
ans = [None] * (N+1)
ok = False
for ans[0], ans[1] in product('SW', 'SW'):
    for i in range(1, N):
        ans[i+1] = next_sw(S[i], ans[i], ans[i-1])
    if ans[0] == ans[-1] and ans[-1] == next_sw(S[0], ans[0], ans[1]):
        ok = True
        break
if ok:
    print(''.join(ans[:N]))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
#最初の二人だけ全探索
#x -> 狼
#o -> 羊
def check(li):
    for i in range(1,n-1):
        if li[i] == 'S':
            if li[i-1] == 'S':
                if s[i] == 'o':
                    li += ['S']
                else:
                    li += ['W']
            else:
                if s[i] == 'o':
                    li += ['W']
                else:
                    li += ['S']
        else:
            if li[i-1] == 'S':
                if s[i] == 'o':
                    li += ['W']
                else:
                    li += ['S']
            else:
                if s[i] == 'o':
                    li += ['S']
                else:
                    li += ['W']
    if li[-1] == 'S':
        if s[-1] == 'o':
            if li[-2] != li[0]:
                return False
        else:
            if li[-2] == li[0]:
                return False
    else:
        if s[-1] == 'o':
            if li[-2] == li[0]:
                return False
        else:
            if li[-2] != li[0]:
                return False
    return li
for i in range(2):
    for j in range(2):
        s1 = 'S' if i == 1 else 'W'
        s2 = 'S' if j == 1 else 'W'
        k = check([s1,s2])
        if k:
            print("".join(k))
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())

Pattern = [['S', 'S'], ['S', 'W'], ['W', 'S'], ['W', 'W']]

def check(n, s, S):
    for i in range(1, n):
        if s[i] == 'o':
            if S[i] == 'S':
                S.append(S[i-1])
            elif S[i] == 'W':
                if S[i-1] == 'W':
                    x = 'S'
                else:
                    x = 'W'
                S.append(x)
        elif s[i] == 'x':
            if S[i] == 'S':
                if S[i-1] == 'W':
                    x = 'S'
                else:
                    x = 'W'
                S.append(x)
            elif S[i] == 'W':
                S.append(S[i-1])
    
    
    if S[0] == S[-1]:
        # s[0]checkを行う
        if s[0] == 'o':
            if S[0] == S[1]:
                if S[-2] == 'S':
                    return S
                else:
                    return False
            else:
                if S[-2] == 'W':
                    return False
                else:
                    return S
        elif s[0] == 'x':
            if S[0] == S[1]:
                if S[-2] == 'W':
                    return S
                else:
                    return False
            else:
                if S[-2] == 'S':
                    return False
                else:
                    return S
    else:
        return False

ans = -1
for pattern in Pattern:
    check_pattern = check(n,s,pattern)
    if check_pattern == False:
        pass
    else:
        ans = check_pattern

if ans != -1:
    ans = ''.join(ans[:n])

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())

Pattern = [['S', 'S'], ['S', 'W'], ['W', 'S'], ['W', 'W']]

def check(n, s, S):
    for i in range(1, n):
        if s[i] == 'o':
            if S[i] == 'S':
                S.append(S[i-1])
            elif S[i] == 'W':
                if S[i-1] == 'W':
                    x = 'S'
                else:
                    x = 'W'
                S.append(x)
        elif s[i] == 'x':
            if S[i] == 'S':
                if S[i-1] == 'W':
                    x = 'S'
                else:
                    x = 'W'
                S.append(x)
            elif S[i] == 'W':
                S.append(S[i-1])
    # print(S)
    if S[0] == S[-1]:
        return S
    else:
        return False

ans = -1
for pattern in Pattern:
    check_pattern = check(n,s,pattern)
    if check_pattern == False:
        pass
    else:
        ans = check_pattern

if ans != -1:
    ans = ''.join(ans[:n])

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())

Pattern = [['S', 'S'], ['S', 'W'], ['W', 'S'], ['W', 'W']]

def check(n, s, S):
    for i in range(1, n):
        if s[i] == 'o':
            if S[i] == 'S':
                S.append(S[i-1])
            elif S[i] == 'W':
                if S[i-1] == 'W':
                    x = 'S'
                else:
                    x = 'W'
                S.append(x)
        elif s[i] == 'x':
            if S[i] == 'S':
                if S[i-1] == 'W':
                    x = 'S'
                else:
                    x = 'W'
                S.append(x)
            elif S[i] == 'W':
                S.append(S[i-1])
    if S[0] == S[-1]:
        return S
    else:
        return False

ans = -1
for pattern in Pattern:
    if check(n, s, pattern) == False:
        pass
    else:
        ans = check(n,s,pattern)

if ans != -1:
    ans = ''.join(ans[:n])

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=input()
L=L.replace('o','1')
L=L.replace('x','0')
L=list(map(int,list(L)))
init = [[1, 1], [1, 0], [0, 1], [0, 0]]
ans = -1
for ii in init:
  ret = [None]*(N)
  ret[0] = ii[1] 
  pR = ii[0]
  for i in range(1, N):
    ret[i]= ~ ((~ (ret[i-1] ^ L[i-1])) ^ pR)
    pR = ret[i-1]
  if ii[0]!=ret[-1]:
    continue
  else:
    ans = ret
    break

if ans == -1:
  print(ans)
else:
  ans=list(map(str,ans))
  ans=''.join(ans)
  ans=ans.replace('1','S')
  ans=ans.replace('0','W')
  print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
s=list(input())
s=list(map(lambda x:0 if x=="o" else 1,s))

#print(s)

ans=[0]*N
ans[0]=1
ans[1]=1
#sheep=0 wolf=1

for _ in range(2):
    ans[0]^=1
    for __ in range(2):
        ans[1]^=1
        for i in range(2,N):
            ans[i]=-1
        for i in range(2,N):
            ans[i]=ans[i-1]^s[i-1]^ans[i-2]
        if s[-1]==ans[-2]^ans[-1]^ans[0]:
            ans=list(map(lambda x:"S" if x==0 else "W", ans))
            print("".join(ans))
            exit()

print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(input())


check = [[1,1],[1,-1],[-1,1],[-1,-1]]
for j,k in check:
    ans = [0]*n
    ans[0] = j
    ans[1] = k
    
    for i in range(1,n):
        if ans[i] == 1:
            if l[i] == "o":
                ans[(i+1)%n] = ans[i-1]
            else:
                ans[(i+1)%n] = -ans[i-1]

        else:
            if l[i] == "o":
                ans[(i+1)%n] = -ans[i-1]
            else:
                ans[(i+1)%n] = ans[i-1]
        
    if j == ans[0]:  
        if l[0]=="o":
            if k == ans[-1]:
                for i in ans:
                    if i == 1:
                        print("S",end="")
                    else:
                        print("W",end="")
                exit()
        else:
            if k == -ans[-1]:
                for i in ans:
                    if i == 1:
                        print("S",end="")
                    else:
                        print("W",end="")
                exit()
        
            
print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(input())


check = [[1,1],[1,-1],[-1,1],[-1,-1]]
for j,k in check:
    ans = [0]*n
    ans[0] = j
    ans[1] = k
    
    for i in range(1,n):
        if ans[i] == 1:
                if l[i] == "o":
                    ans[(i+1)%n] = ans[i-1]
                else:
                    ans[(i+1)%n] = -ans[i-1]

        else:
            if l[i] == "o":
                ans[(i+1)%n] = -ans[i-1]
            else:
                ans[(i+1)%n] = ans[i-1]
        
    if j == ans[0]:  
        if l[0]=="o":
            if k == ans[-1]:
                for i in ans:
                    if i == 1:
                        print("S",end="")
                    else:
                        print("W",end="")
        else:
            if k == -ans[-1]:
                for i in ans:
                    if i == 1:
                        print("S",end="")
                    else:
                        print("W",end="")


        
        exit()
        
            
print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(input())


check = [[1,1],[1,-1],[-1,1],[-1,-1]]
for j,k in check:
    ans = [0]*n
    ans[0] = j
    ans[1] = k
    
    for i in range(1,n):
        if ans[i] == 1:
                if l[i] == "o":
                    ans[(i+1)%n] = ans[i-1]
                else:
                    ans[(i+1)%n] = -ans[i-1]

        else:
            if l[i] == "o":
                ans[(i+1)%n] = -ans[i-1]
            else:
                ans[(i+1)%n] = ans[i-1]
        
    if j == ans[0]:    
        for i in ans:
            if i == 1:
                print("S",end="")
            else:
                print("W",end="")
        exit()
        
            
print(-1)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()
s=[1 if i=='o' else 0 for i in input()]

# 1 true, 0 lie
def check(y):
    t=[0]*n
    t[0],t[1]=y
    p=t[0]
    for i in range(2,n):
        t[i]=t[i-1]^t[i-2]^s[i-1]
    for i in range(n):
        if s[i]!=t[i-1]^t[i]^t[(i+1)%n]:
            t=-1
        return -1
    return t

for i in range(2):
    for j in range(2):
        ans=check((i,j))
        if ans!=-1:
            ans=''.join(['S' if i==1 else 'W' for i in ans])
            print(ans)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()
s=[1 if i=='o' else 0 for i in input()]

# 1 true, 0 lie
def check(y):
    t=[0]*n
    t[0],t[1]=y
    p=t[0]
    for i in range(2,n):
        t[i]=t[i-1]^t[i-2]^s[i-1]
    for i in range(n):
        if s[i]!=t[i-1]^t[i]^t[(i+1)%n]:
            t=-1
        break
    return t

for i in range(2):
    for j in range(2):
        ans=check((i,j))
        if ans!=-1:
            ans=''.join(['S' if i==1 else 'W' for i in ans])
            print(ans)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()
s=[1 if i=='o' else 0 for i in input()]

# 1 true, 0 lie
def check(y):
    t=[0]*n
    t[0],t[1]=y
    p=t[0]
    for i in range(2,n):
        t[i]=t[i-1]^t[i-2]^s[i-1]
    for i in range(n):
        if s[i]!=t[i-1]^t[i]^t[i+1]:
            t=-1
        break
    return t

for i in range(2):
    for j in range(2):
        ans=check((1-i,j))
        if ans!=-1:
            ans=''.join(['S' if i==1 else 'W' for i in ans])
            print(ans)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()
s=[1 if i=='o' else 0 for i in input()]

# 1 true, 0 lie
def check(y):
    t=[0]*n
    t[0],t[1]=y
    p=t[0]
    for i in range(2,n):
        t[i]=t[i-1]^t[i-2]^s[i-1]
    for i in range(n):
        if t[i]!=t[i-1]^t[i-2]^s[i-1]:
            t=-1
        break
    return t

for i in range(2):
    for j in range(2):
        ans=check((1-i,j))
        if ans!=-1:
            ans=''.join(['S' if i==1 else 'W' for i in ans])
            print(ans)
            exit()

print(ans)