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
def point(main_animal,main_animal_answer,previous_animal):
    next_animal=''
    if main_animal=='S':
        if main_animal_answer=='o':
            next_animal=previous_animal
        else:
            if previous_animal=='W':
                next_animal='S'
            else:
                next_animal='W'
    else:
        if main_animal_answer=='x':
            next_animal=previous_animal
        else:
            if previous_animal=='W':
                next_animal='S'
            else:
                next_animal='W'
        

    
    
    return next_animal

def cheacker(main_animal,main_animal_answer,previous_animal,next_animal):
    if (main_animal=="S" and main_animal_answer=="o")or(main_animal=='W' and main_animal_answer=='x' ):
        if(previous_animal==next_animal):
            return True
        else:
            return False
    elif (main_animal=="S"and main_animal_answer=="x")or(main_animal=="W" and main_animal_answer=="o"):
        if(previous_animal!=next_animal):
            return True
        else:
            return False
    else:
        return False

def cheack_list(animal_list,answer_list):
    final_ans=True
    for i in range(1,len(animal_list)-2):
        if i==1:
            ans=cheacker(animal_list[i],answer_list[i],animal_list[len(animal_list)-1],animal_list[i+1])
        else:
            ans=cheacker(animal_list[i],answer_list[i],animal_list[i-1],animal_list[i+1])
        if ans==False:
            final_ans=False
        else:
            pass
    return final_ans

N=input()
str=input()
answer_list=[]
animal_list=[]
for i in str:
    answer_list.append(i)

animal_list.append("S")
animal_list.append("S")

for i in range(1,len(answer_list)-1):
    animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1]))

ans=cheack_list(animal_list,answer_list)
if ans:
    print(animal_list)
    sys.exit
del animal_list[:]


animal_list.append("S")
animal_list.append("W")

for i in range(1,len(answer_list)-1):
    animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1]))

ans2=cheack_list(animal_list,answer_list)
if ans2:
    print(animal_list)
    sys.exit
del animal_list[:]


animal_list.append("W")
animal_list.append("S")

for i in range(1,len(answer_list)-1):
    animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1]))

ans2=cheack_list(animal_list,answer_list)
if ans2:
    print(animal_list)
    sys.exit
del animal_list[:]


animal_list.append("W")
animal_list.append("W")

for i in range(1,len(answer_list)-1):
    animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1]))

ans2=cheack_list(animal_list,answer_list)
if ans2:
    print(animal_list)
    sys.exit

print(-1)

Submission status: Wrong Answer

Solution code:
import sys

def SorW(i):
    if i == 0:
        n = N - 1
    else:
        n = i - 1
    if t[i] == 'S' and t[n] == 'S':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    elif t[i] == 'S' and t[n] == 'W':
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    elif t[i] == 'W' and t[n] == 'W':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    else:
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    return a

N = int(input())
s = str(input())

for t in [['S', 'S'], ['S', 'W'], ['W', 'W'], ['W', 'S']]:
    for i in range(1, N):
        t.append(SorW(i))
    if t[0] == t[N] and t[1] == SorW(0):
        del t[N]
        print(t)
        sys.exit()
print(-1)

Submission status: Wrong Answer

Solution code:
import sys

def SorW(i):
    if i == 0:
        n = N - 1
    else:
        n = i - 1
    if t[i] == 'S' and t[n] == 'S':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    elif t[i] == 'S' and t[n] == 'W':
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    elif t[i] == 'W' and t[n] == 'W':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    else:
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    return a

N = int(input())
s = str(input())

for t in [['S', 'S'], ['S', 'W'], ['W', 'W'], ['W', 'S']]:
    for i in range(1, N):
        t.append(SorW(i))
    if t[0] == t[N] and t[1] == SorW(0):
        del t[N]
        print(t)
        sys.exit()
print('-1')

Submission status: Wrong Answer

Solution code:
import sys

def SorW(i):
    if i == 0:
        n = N - 1
    else:
        n = i - 1
    if t[i] == 'S' and t[n] == 'S':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    elif t[i] == 'S' and t[n] == 'W':
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    elif t[i] == 'W' and t[n] == 'W':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    else:
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    return a

N = int(input())
s = str(input())

for t in [['S', 'S'], ['S', 'W'], ['W', 'W'], ['W', 'S']]:
    for i in range(1, N):
        t.append(SorW(i))
    if t[0] == t[N - 1] and t[1] == SorW(0):
        del t[N - 1]
        print(t)
        sys.exit()
print('-1')

Submission status: Wrong Answer

Solution code:
import sys

def SorW(i):
    if t[i] == 'S' and t[i - 1] == 'S':
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    elif t[i] == 'S' and t[i - 1] == 'W':
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    elif t[i] == 'W' and t[i - 1] == 'S':
        if s[i] == 'o':
            a = 'W'
        else:
            a = 'S'
    else:
        if s[i] == 'o':
            a = 'S'
        else:
            a = 'W'
    return a

N = int(input())
s = str(input())

for t in [['S', 'S'], ['S', 'W'], ['W', 'W'], ['W', 'S']]:
    for i in range(1, N):
        t.append(SorW(i))
        if i == N - 1:
            if t[0] == t[N - 1] and t[1] == SorW(0):
                del t[N - 1]
                print(t)
                sys.exit()
print('-1')

Submission status: Wrong Answer

Solution code:
from itertools import product

N = int(raw_input())
ox = [c == 'o' for c in raw_input()]

SHEEP, WOLF = 0, 1
a = [None] * N

for s1, s2 in product([SHEEP, WOLF], repeat=2):
    a[0], a[1] = s1, s2
    for i in xrange(2, N):
        if ox[i - 1]:
            if a[i - 1] == SHEEP:
                a[i] = a[i - 2]
            else:
                a[i] = 1 - a[i - 2]
        else:
            if a[i - 1] == SHEEP:
                a[i] = 1 - a[i - 2]
            else:
                a[i] = a[i - 2]
    if ox[-1]:
        if (a[-1] == SHEEP and a[0] == a[-2]) or (a[-1] == WOLF and a[0] != a[-2]):
            print ''.join('SW'[a[i]] for i in xrange(N))
            break
    else:
        if (a[-1] == SHEEP and a[0] != a[-2]) or (a[-1] == WOLF and a[0] == a[-2]):
            print ''.join('SW'[a[i]] for i in xrange(N))
            break
else:
    print -1

Submission status: Wrong Answer

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

def invert(a):
    return 'S' if a == 'W' else 'W'


def inference(a, b, p, q):
    if isinstance(p, str):
        p = 'o' == p
    if isinstance(q, str):
        q = 'o' == q
    if not ((b == 'S') != (q)):
        next = a
    else:
        next = invert(a)
    return next


def solve():
    for ans1 in ['S', 'W']:
        for ans2 in ['S', 'W']:
            ans = []
            next2 = inference(ans1, ans2, s[0] == 'o', s[1] == 'o')
            next1 = ans2
            ans.append(ans1)
            ans.append(next1)
            for i in range(1, N-1):
                ans.append(next2)
                _next2 = inference(next1, next2, s[i], s[i+1])
                next1, next2 = next2, _next2
            if next2 == ans1:
                return ''.join(ans)
    return -1

print(solve())

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import sys
N=int(input())
Say=input()
A1='SS'
A2='WS'
A3='SW'
A4='WW'
def Nextone(a,b,w):
    if w=='o':
        if a=='S' and b=='S':
            return 'S'
        elif a=='W' and b=='S':
            return 'W'
        elif a=='S' and b=='W':
            return 'W'
        else:
            return 'S'
    else:
        if a=='S' and b=='S':
            return 'W'
        elif a=='W' and b=='S':
            return 'S'
        elif a=='S' and b=='W':
            return 'S'
        else:
            return 'W'

for i in range(0,N):
    A1+=Nextone(A1[i],A1[i+1],Say[i])
    A2+=Nextone(A2[i],A2[i+1],Say[i])
    A3+=Nextone(A3[i],A3[i+1],Say[i])
    A4+=Nextone(A4[i],A4[i+1],Say[i])
if A1[1]==A1[N+1]:
    print(A1[1:N+1])
elif A2[1]==A2[N+1]:
    print(A2[1:N+1])
elif A3[1]==A3[N+1]:
    print(A3[1:N+1])
elif A4[1]==A4[N+1]:
    print(A4[1:N+1])
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import sys
N=int(input())
Say=input()
A1='SS'
A2='WS'
A3='SW'
A4='WW'
def Nextone(a,b,w):
    if w=='o':
        if a=='S' and b=='S':
            return 'S'
        elif a=='W' and b=='S':
            return 'W'
        elif a=='S' and b=='W':
            return 'W'
        else:
            return 'S'
    else:
        if a=='S' and b=='S':
            return 'W'
        elif a=='W' and b=='S':
            return 'S'
        elif a=='S' and b=='W':
            return 'S'
        else:
            return 'W'

for i in range(0,N):
    A1+=Nextone(A1[i],A1[i+1],Say[i])
    A2+=Nextone(A2[i],A2[i+1],Say[i])
    A3+=Nextone(A3[i],A3[i+1],Say[i])
    A4+=Nextone(A4[i],A4[i+1],Say[i])
if A1[1]==A1[N+1]:
    print(A1[1:N+1])
    sys.exit()
elif A2[1]==A2[N+1]:
    print(A2[1:N+1])
    sys.exit()
elif A3[1]==A3[N+1]:
    print(A3[1:N+1])
    sys.exit()
elif A4[1]==A4[N+1]:
    print(A4[1:N+1])
    sys.exit()
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import sys
N=int(input())
Say=input()
A1='SS'
A2='WS'
A3='SW'
A4='WW'
def Nextone(a,b,w):
    if w=='o':
        if a=='S' and b=='S':
            return 'S'
        elif a=='W' and b=='S':
            return 'W'
        elif a=='S' and b=='W':
            return 'W'
        else:
            return 'S'
    else:
        if a=='S' and b=='S':
            return 'W'
        elif a=='W' and b=='S':
            return 'S'
        elif a=='S' and b=='W':
            return 'S'
        else:
            return 'W'

for i in range(0,N):
    A1+=Nextone(A1[i],A1[i+1],Say[i])
    A2+=Nextone(A2[i],A2[i+1],Say[i])
    A3+=Nextone(A3[i],A3[i+1],Say[i])
    A4+=Nextone(A4[i],A4[i+1],Say[i])
if A1[1]==A1[N+1]:
    print(A1[1:N+1])
    sys.exit()
elif A2[1]==A2[N+1]:
    print(A2[1:N+1])
    sys.exit()
elif A3[1]==A3[N+1]:
    print(A3[1:N+1])
    sys.exit
elif A4[1]==A4[N+1]:
    print(A4[1:N+1])
    sys.exit()
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import sys
N=int(input())
Say=input()
A1='SS'
A2='WS'
A3='SW'
A4='WW'
def Nextone(a,b,w):
    if w=='o':
        if a=='S' and b=='S':
            return 'S'
        elif a=='W' and b=='S':
            return 'W'
        elif a=='S' and b=='W':
            return 'W'
        else:
            return 'S'
    else:
        if a=='S' and b=='S':
            return 'W'
        elif a=='W' and b=='S':
            return 'S'
        elif a=='S' and b=='W':
            return 'S'
        else:
            return 'W'

for i in range(0,N):
    A1+=Nextone(A1[i],A1[i+1],Say[i])
    A2+=Nextone(A2[i],A2[i+1],Say[i])
    A3+=Nextone(A3[i],A3[i+1],Say[i])
    A4+=Nextone(A4[i],A4[i+1],Say[i])
if A1[1]==A1[N+1]:
    print(A1[1:N+1])
    sys.exit()
elif A2[1]==A2[N+1]:
    print(A2[1:N+1])
    print(A2)
    sys.exit()
elif A3[1]==A3[N+1]:
    print(A3[1:N+1])
    sys.exit
elif A4[1]==A4[N+1]:
    print(A4[1:N+1])
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import sys
N=int(input())
Say=input()
A1='SS'
A2='WS'
A3='SW'
A4='WW'
def Nextone(a,b,w):
    if w=='o':
        if a=='S' and b=='S':
            return 'S'
        elif a=='W' and b=='S':
            return 'W'
        elif a=='S' and b=='W':
            return 'W'
        else:
            return 'S'
    elif w=='x':
        if a=='S' and b=='S':
            return 'W'
        elif a=='W' and b=='S':
            return 'S'
        elif a=='S' and b=='W':
            return 'S'
        else:
            return 'W'
    else:
        sys.exit()

for i in range(0,N):
    A1+=Nextone(A1[i],A1[i+1],Say[i])
    A2+=Nextone(A2[i],A2[i+1],Say[i])
    A3+=Nextone(A3[i],A3[i+1],Say[i])
    A4+=Nextone(A4[i],A4[i+1],Say[i])
if A1[1]==A1[N+1]:
    print(A1[1:N+1])
    sys.exit()
elif A2[1]==A2[N+1]:
    print(A2[1:N+1])
    print(A2)
    sys.exit()
elif A3[1]==A3[N+1]:
    print(A3[1:N+1])
    sys.exit
elif A4[1]==A4[N+1]:
    print(A4[1:N+1])
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
s = list(map(lambda x: True if x == "o" else False, list(input())))

f = lambda x,y: not(x^y)

def hantei(N,s):
    for onetwo in itertools.product((True, False), (True, False)):
        res = {}
        for n in range(N):
            if n == 0:
                res[n] = onetwo[0]
            elif n == 1:
                res[n] = onetwo[1]
            else:
                res[n] = f(res[n-2], f(res[n-1], s[n-1]))
        # check s[0]
        if not ((res[1] == res[N-1]) ^ res[0]) == s[0]:
            if not ((res[0] == res[N-2]) ^ res[N-1]) == s[N-1]:
                print(''.join(map(lambda x: "S" if x == 0 else "W", res.values())))
                return True

    return False

if not hantei(N, s):
    print(-1)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
s = list(map(lambda x: True if x == "o" else False, list(input())))

# N = 6
# s = "ooxoox"
# N = 3
# s = "oox"
# s = [True, True, False]

f = lambda x,y: not(x^y)

def hantei(N,s):
    for onetwo in itertools.product((True, False), (True, False)):
        res = {}
        for n in range(N):
            if n == 0:
                res[n] = onetwo[0]
            elif n == 1:
                res[n] = onetwo[1]
            else:
                res[n] = f(res[n-2], f(res[n-1], s[n-1]))
        # check s[0]
        if not ((res[1] == res[N-1]) ^ res[0]) == s[0]:
            if not ((res[0] == res[N-2]) ^ res[N-1]) == s[N-1]:
                print(''.join(map(lambda x: "S" if x == 0 else "W", res.values())))
                return True

    return False

if not hantei(N, s):
    print(-1)

Submission status: Wrong Answer

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

r = {'S' : 'W', 'W': 'S'}

a = 'SS'
ans = -1
for a in ('SS', 'SW', 'WS', 'WW'):
    for i in range(1,N):
        if s[i] == 'o':
            if a[i] == 'S':
                a += a[i-1]
            else:
                a += r[a[i-1]]
        else:
            if a[i] == 'S':
                a += r[a[i-1]]
            else:
                a += a[i-1]
    if a[N] == a[0]:
        if (s[0] == 'o') and (a[N-1] == a[1]):
            ans = a[:-1]
        elif (s[0] == 'x') and (a[N-1] == r[a[1]]):
            ans = a[:-1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = str(input())
ss = s
l = len(s)

F = 0
for i in range(int(l/2)+1):
    t = ss[i:]+ss[:i]
    if (N%2 == 1 and t[:int(l/2)]==t[int(l/2)+1:]) or\
            (N%2 == 0 and t[:int(l/2)]*2 == t):
        F = 1
        break
if F==0:
    print(-1)
else:
    ans = ''
    Flag = 0
    for c in s:
        if Flag == 0:
            ans += 'S'
            if c == 'x':
                Flag = 1
        else:
            if c == 'x':
                ans += 'S'
                Flag = 0
            else:
                ans += 'W'
    print(ans)

Submission status: Wrong Answer

Solution code:
n =int(input())
s = input()
s = list(s)
for i in range(len(s)):
    if s[i] =='o':
        s[i] = int(1)
    else:
        s[i] = int(-1)

syoki_list = [[1,1],[1,-1],[-1,1],[-1,-1]]
a = "-1"
for i in range(len(syoki_list)):
    t = []
    t.append(syoki_list[i][0])
    t.append(syoki_list[i][1])
    for j in range(2,n+1):
        t.append(t[j-2] * t[j-1] * s[j-1])
    if t[0] ==t[n] and t[1] == t[n] * t[0]*s[0]:
        for i in range(n+1):
            if t[i] == 1:
                t[i] = "S"
            else:
                t[i] = "W"
        a= "".join(t[:n])
        break

print(a)

Submission status: Wrong Answer

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

r = {'S' : 'W', 'W': 'S'}

a = 'SS'
ans = -1
for a in ('SS', 'SW', 'WS', 'WW'):
    for i in range(1,N):
        if s[i] == 'o':
            if a[i] == 'S':
                a += a[i-1]
            else:
                a += r[a[i-1]]
        else:
            if a[i] == 'S':
                a += r[a[i-1]]
            else:
                a += a[i-1]
    if a[N] == a[0]:
        if s[0] == 'o' and (a[N-1] == a[1]):
            ans = a[:-1]
        elif s[0] == 'x' and (a[N-1] == r[a[1]]):
            ans = a[:-1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = str(input())
ss = s

F = 0
for i,_ in enumerate(ss):
    t = ss[i:]+ss[:i]
    if (N%2 == 1 and t[:int(len(s)/2)]==t[int(len(s)/2)+1:]) or\
            (N%2 == 0 and t[:int(len(s)/2)]*2 == s):
        F = 1
        break
if F==0:
    print(-1)
else:
    ans = ''
    Flag = 0
    for c in s:
        if Flag == 0:
            ans += 'S'
            if c == 'x':
                Flag = 1
        else:
            if c == 'x':
                ans += 'S'
                Flag = 0
            else:
                ans += 'W'
    print(ans)

Submission status: Wrong Answer

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

r = {'S' : 'W', 'W': 'S'}

a = 'SS'
ans = -1
for a in ('SS', 'SW', 'WS', 'WW'):
    for i in range(1,N):
        if s[i] == 'o':
            if a[i] == 'S':
                a += a[i-1]
            else:
                a += r[a[i-1]]
        else:
            if a[i] == 'S':
                a += r[a[i-1]]
            else:
                a += a[i-1]
    if a[N] == a[0]:
        if s[0] == 'o' and (a[N] == a[1]):
            ans = a[:-1]
        elif s[0] == 'x' and (a[N] == r[a[1]]):
            ans = a[:-1]
print(ans)

Submission status: Wrong Answer

Solution code:
def flip(c):
    if c=='S':
        return 'W'
    else:
        return 'S'

def judge():
    found=False
    ret = -1
    for i in xrange(N):
        #print r
        if r[i]=='S':
            if s[i]=='o':
                if i==0:
                    r[i-1]=r[i+1]
                elif i==N-1:
                    if r[0]==r[i-1]:
                        found=True
                else:
                    r[i+1]=r[i-1]
            else:
                if i==0:
                    r[i-1]=flip(r[i+1])
                elif i==N-1:
                    if r[0]==flip(r[i-1]):
                        found=True
                else:
                    r[i+1]=flip(r[i-1])
        else: # W
            if s[i]=='x':
                if i==0:
                    r[i-1]=r[i+1]
                elif i==N-1:
                    if r[0]==r[i-1]:
                        found=True
                else:
                    r[i+1]=r[i-1]
            else:
                if i==0:
                    r[i-1]=flip(r[i+1])
                elif i==N-1:
                    if r[0]==flip(r[i-1]):
                        found=True
                else:
                    r[i+1]=flip(r[i-1])
                
        if found:
            ret = ''.join(r)

    return ret
    
N=input()
s=list(raw_input())


ptn=[['S','S'],['S','W'],['W','S'],['W','W']]

ret = None
for p in ptn:
    r = [None]*N
    r[0]=p[0]
    r[1]=p[1]
    ret = judge()
    if ret != -1:
        break
print ret

Submission status: Wrong Answer

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

count = 0

def cvt_sw(li):
    ans = ""
    for i in li:
        if i == 1:
            ans += "W"
        else:
            ans += "S"
    return ans


while count < 2:
    if count == 0:
        t = [1 for i in range(n)] # t[i] = 0 => 羊 t[i] = 1 => 狼
    elif count == 1:
        t = [0 for i in range(n)] # t[i] = 0 => 羊 t[i] = 1 => 狼

    for i in range(n - 1):
        if t[i] == 1:
            # 狼のとき
            if s[i] == 'o' and t[i - 1] == t[i + 1]:
                t[i + 1] = (t[i - 1] + 1) % 2
            elif s[i] == 'x' and t[i - 1] != t[i + 1]:
                t[i + 1] = t[i - 1]
        else:
            # 羊の時
            if s[i] == 'o' and t[i - 1] != t[i + 1]:
                t[i + 1] = t[i - 1]
            elif s[i] == 'x' and t[i - 1] == t[i + 1]:
                t[i + 1] = (t[i - 1] + 1) % 2

    if t[n - 1] == 1:
        if s[n - 1] == 'o' and t[n - 2] != t[1]:
            # 正しい
            print(cvt_sw(t))
            break
        elif s[n - 1] == 'x' and t[n - 1] == t[1]:
            print(cvt_sw(t))
            break
    else:
        if s[n - 1] == 'o' and t[n - 2] == t[1]:
            print(cvt_sw(t))
            break
        elif s[n - 1] == 'x' and t[n - 2] != t[1]:
            print(cvt_sw(t))
            break
    count += 1

if count == 2:
    print(-1)

Submission status: Wrong Answer

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

if (N%2 == 1 and s[:int(len(s)/2)]!=s[int(len(s)/2)+1:]) or\
        (N%2 == 0 and s[:int(len(s)/2)]*2 != s):
    print(-1)
else:
    ans = ''
    Flag = 0
    for c in s:
        if Flag == 0:
            ans += 'S'
            if c == 'x':
                Flag = 1
        else:
            if c == 'x':
                ans += 'S'
                Flag = 0
            else:
                ans += 'W'
    print(ans)

Submission status: Wrong Answer

Solution code:
n =int(input())
s = input()
s = list(s)
for i in range(len(s)):
    if s[i] =='o':
        s[i] = int(1)
    else:
        s[i] = int(-1)

syoki_list = [[1,1],[1,-1],[-1,1],[-1,-1]]
a = "-1"
for i in range(len(syoki_list)):
    t = []
    t.append(syoki_list[i][0])
    t.append(syoki_list[i][1])
    for j in range(2,n+1):
        t.append(t[j-2] * t[j-1] * s[j-1])
    if t[0] == t[n]:
        for i in range(n+1):
            if t[i] == 1:
                t[i] = "S"
            else:
                t[i] = "W"
        a= "".join(t[:n])
        break

print(a)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
ipt = list(input())
stR = ["S" for i in range(N)]
stR[1] = "W"
def sheep(stg):
     return stg
def wolf(stg):
    if stg == "S":
        return "W"
    else:
        return "S"
def modN (i):
    return i%N

if set(ipt) == {"o"}:
    print("S"*N)
    sys.exit()
elif set(ipt) == {"x"}:
    print("W"*N)
    sys.exit()

for i in range(N+2):
    if stR[modN(i+1)] == "S" and ipt[modN(i+1)]=="o"  :
        stR[modN(i+2)]=sheep(stR[modN(i)])
    elif stR[modN(i+1)] == "W" and ipt[modN(i+1)]=="x":
        stR[modN(i+2)]=sheep(stR[modN(i)])
    else:
        stR[modN(i+2)]=wolf(stR[modN(i)])

if stR[0]=="S" and stR[1]=="W":
    print("".join(stR))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = str(input())
ss = s

if N%2 == 1:
    s += s[0]
if s[:int(len(s)/2)]*2 != s:
    print(-1)
else:
    ans = ''
    Flag = 0
    for c in ss:
        if Flag == 0:
            ans += 'S'
            if c == 'x':
                Flag = 1
        else:
            if c == 'x':
                ans += 'S'
                Flag = 0
            else:
                ans += 'W'
    print(ans)

Submission status: Wrong Answer

Solution code:
n =int(input())
s = input()
s = list(s)
for i in range(len(s)):
    if s[i] =='o':
        s[i] = int(1)
    else:
        s[i] = int(-1)

syoki_list = [[1,1],[1,-1],[-1,1],[-1,-1]]
t = []
a = "-1"
for i in range(len(syoki_list)):
    t.append(syoki_list[i][0])
    t.append(syoki_list[i][1])
    for j in range(2,n+1):
        t.append(t[j-2] * t[j-1] * s[j-1])
    if t[0] == t[n]:
        for i in range(n+1):
            if t[i] == 1:
                t[i] = "S"
            else:
                t[i] = "W"
        a= "".join(t[:n])
        break

print(a)

Submission status: Wrong Answer

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

def lier_check(aa):
    lier = 1
    if aa==0:
        mae=N-1
    else:
        mae=aa-1
    if aa == N-1:
        ato = 0
    else:
        ato = aa+1
    
    if ans[aa] == 'S' and s[aa] == 'o':
        if ans[mae] != ans[ato]:
            lier = -1
    if ans[aa] == 'S' and s[aa] == 'x':
        if ans[mae] == ans[ato]:
            lier = -1
    if ans[aa] == 'W' and s[aa] == 'o':
        if ans[mae] == ans[ato]:
            lier = -1
    if ans[aa] == 'W' and s[aa] == 'x':
        if ans[mae] != ans[ato]:
            lier = -1 
    return(lier)


ans = ['X']*N
ans[0] = 'S'
if s[0] == 'o':
    ans[N-1] = 'S'
    ans[1] = 'S'
else:
    ans[N-1] = 'W'
    ans[1] = 'S'
for aa in range(1,N-1):
    if ans[aa] == 'S' and s[aa] == 'o' and ans[aa-1]=='S':
        ans[aa+1] = 'S'
    elif ans[aa] == 'S' and s[aa] == 'o' and ans[aa-1]=='W':
        ans[aa+1] = 'W'
    elif ans[aa] == 'S' and s[aa] == 'x' and ans[aa-1]=='S':
        ans[aa+1] = 'W'
    elif ans[aa] == 'S' and s[aa] == 'x' and ans[aa-1]=='W':
        ans[aa+1] = 'S'
    elif ans[aa] == 'W' and s[aa] == 'o' and ans[aa-1]=='S':
        ans[aa+1] = 'W'
    elif ans[aa] == 'W' and s[aa] == 'o' and ans[aa-1]=='W':
        ans[aa+1] = 'S'
    elif ans[aa] == 'W' and s[aa] == 'x' and ans[aa-1]=='S':
        ans[aa+1] = 'S'
    elif ans[aa] == 'W' and s[aa] == 'x' and ans[aa-1]=='W':
        ans[aa+1] = 'W'

kekka = 1
for aa in range(0,len(ans)):
    if(lier_check(aa) == -1):
        kekka = -1
        break
if kekka == -1:
    print(kekka)
else:
    print("".join(ans))

Submission status: Wrong Answer

Solution code:
from itertools import product as prod

n = int(input())
ss = list(input())

def next_anim(a_0, a_1, s):
    if s == "o":
        if a_1 == "S":
            return a_0
        else:
            return "W" if a_0 == "S" else "S"
    else:
        if a_1 == "S":
            return "W" if a_0 == "S" else "S"
        else:
            return a_0

ans = -1
anims = ["" for _ in range(n)]
for fst, snd in prod(["W", "S"], repeat=2):
    anims[:2] = [fst, snd]
    for i in range(2, n):
        anims[i] = next_anim(anims[i-2], anims[i-1], ss[i-1])
    tmp_anim2 = next_anim(anims[-2], anims[-1], ss[-1])
    if tmp_anim2 == anims[0]:
        ans = "".join(anims)
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = list(input())
Ans = ['n' for _ in t]

def judge(prevSW, SW, ox):
    if SW == 'S':
        if ox == 'o':
            return prevSW
        else:
            if prevSW == 'S':
                return 'W'
            else: return 'S'
    elif SW == 'W':
        if ox == 'x':
            return prevSW
        else:
            if prevSW == 'S':
                return 'W'
            else: return 'S'

def decideorder(startSW):
    Ans[1] = startSW
    for i in range(2,N):
        Ans[i] = judge(Ans[i-2], Ans[i-1], t[i-1])


Ans[0] = 'S'
decideorder('S')
if judge(Ans[-2], Ans[-1], t[-1]) is Ans[0]:
    print("".join(Ans))
else:
    decideorder('W')
    if judge(Ans[-2], Ans[-1], t[-1]) is Ans[0]:
        print("".join(Ans))
    else:
        Ans[0] = 'W'
        decideorder('S')
        if judge(Ans[-2], Ans[-1], t[-1]) is Ans[0]:
            print("".join(Ans))
        else:
            decideorder('W')
            if judge(Ans[-2], Ans[-1], t[-1]) is Ans[0]:
                print("".join(Ans))
            else:
                print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = list(input())
Ans = ['n' for _ in t]

def judge(prevSW, SW, ox):
    if SW == 'S':
        if ox == 'o':
            return prevSW
        else:
            if prevSW == 'S':
                return 'W'
            else: return 'S'
    elif SW == 'W':
        if ox == 'x':
            return prevSW
        else:
            if prevSW == 'S':
                return 'W'
            else: return 'S'

def decideorder(startSW):
    Ans[1] = startSW
    for i in range(2,N):
        Ans[i] = judge(Ans[i-2], Ans[i-1], t[i-1])


Ans[0] = 'S'
decideorder('S')
if judge(Ans[-1], Ans[0], t[0]) is Ans[0]:
    print("".join(Ans))
else:
    decideorder('W')
    if judge(Ans[-1], Ans[0], t[0]) is Ans[0]:
        print("".join(Ans))
    else:
        Ans[0] = 'W'
        decideorder('S')
        if judge(Ans[-1], Ans[0], t[0]) is Ans[0]:
            print("".join(Ans))
        else:
            decideorder('W')
            if judge(Ans[-1], Ans[0], t[0]) is Ans[0]:
                print("".join(Ans))
            else:
                print(-1)