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:
n=int(input())
arr=input()
ans=['S']*n
for i in range(n):
  if arr[i]=='o':
    if ans[i]=='S':
      if ans[i-1]==ans[(i+1)%n]:
        continue
      else:
        ans[(i+1)%n]=ans[i-1]
    elif ans[i]=='W':
      if ans[i-1]!=ans[(i+1)%n]:
        continue
      else:
        if ans[(i+1)%n]=='S':
          ans[(i+1)%n]='W'
        else:
          ans[(i+1)%n]='S'
  elif arr[i]=='x':
    if ans[i]=='S':
      if ans[i-1]==ans[(i+1)%n]:
        if ans[(i+1)%n]=='S':
          ans[(i+1)%n]='W'
        else:
          ans[(i+1)%n]='S'
      else:
        continue
    elif ans[i]=='W':
      if ans[i-1]==ans[(i+1)%n]:
        continue
      else:
        if ans[(i+1)%n]=='S':
          ans[(i+1)%n]='W'
        else:
          ans[(i+1)%n]='S'
flag=False
for i in range(n):
  if arr[i]=='o':
    if ans[i]=='S':
      if ans[i-1]==ans[(i+1)%n]:
        continue
      else:
        break
    elif ans[i]=='W':
      if ans[i-1]!=ans[(i+1)%n]:
        continue
      else:
        break
  elif arr[i]=='x':
    if ans[i]=='S':
      if ans[i-1]==ans[(i+1)%n]:
        break
      else:
        continue
    elif ans[i]=='W':
      if ans[i-1]==ans[(i+1)%n]:
        continue
      else:
        break
else:
  flag=True
if flag==True:
  print(''.join(map(str,ans)))
else:
  ans=['W']*n
  for i in range(n):
    if arr[i]=='o':
      if ans[i]=='S':
        if ans[i-1]==ans[(i+1)%n]:
          continue
        else:
          ans[(i+1)%n]=ans[i-1]
      if ans[i]=='W':
        if ans[i-1]!=ans[(i+1)%n]:
          continue
        else:
          if ans[(i+1)%n]=='S':
            ans[(i+1)%n]='W'
          else:
            ans[(i+1)%n]='S'
    elif arr[i]=='x':
      if ans[i]=='S':
        if ans[i-1]==ans[(i+1)%n]:
          if ans[(i+1)%n]=='S':
            ans[(i+1)%n]='W'
          else:
            ans[(i+1)%n]='S'
        else:
          continue
      if ans[i]=='W':
        if ans[i-1]==ans[(i+1)%n]:
          continue
        else:
          if ans[(i+1)%n]=='S':
            ans[(i+1)%n]='W'
          else:
            ans[(i+1)%n]='S'
  flag=False
  for i in range(n):
    if arr[i]=='o':
      if ans[i]=='S':
        if ans[i-1]==ans[(i+1)%n]:
          continue
        else:
          break
      if ans[i]=='W':
        if ans[i-1]!=ans[(i+1)%n]:
          continue
        else:
          break
    elif arr[i]=='x':
      if ans[i]=='S':
        if ans[i-1]==ans[(i+1)%n]:
          break
        else:
          continue
      if ans[i]=='W':
        if ans[i-1]==ans[(i+1)%n]:
          continue
        else:
          break
  else:
    flag=True
  if flag==True:
    print(''.join(map(str,ans)))
  else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input()
t = [None] * N
for a in [0, 1]:
    for b in [0, 1]:
        t[0], t[1] = a, b
        if a == 0:
            if s[0] == 'o':
                last = b
            else:
                last = b^1
        else:
            if s[0] == 'o':
                last = b^1
            else:
                last = b
        for i in range(1, N):
            if t[i] == 0:
                if s[i] == 'o':
                    t[(i+1)%N] = t[i-1]
                else:
                    t[(i+1)%N] = t[i-1]^1
            else:
                if s[i] == 'o':
                    t[(i+1)%N] = t[i-1]^1
                else:
                    t[(i+1)%N] = t[i-1]
        if a == t[0]:
            ans = ''
            for x in t:
                if x == 0:
                    ans += 'S'
                else:
                    ans += 'W'
            print(ans)
            quit()
print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

# Sの値を+-1にする
for i in range(N) :
    if S[i] == 'o' :
        S[i] = 1
    else :
        S[i] = -1

S.append(S[0])

def check() :
    for first in [1, -1] :
        for second in [1, -1] :
            animal = [1] * (N + 2)
            animal[0] = first
            animal[1] = second
            for i in range(1,N+1) :
                if animal[i] == 1 :  # 動物が羊の場合
                    animal[i+1] = animal[i-1] *  S[i]
                else :  # 動物が狼の場合
                    animal[i+1] = animal[i-1] * S[i] * (-1)
            if animal[1] == animal[-1] :
                return animal
    return -1

ans = check()

if ans == -1 :
    print(-1)
else :
    for i in range(N) :
        if ans[i] == 1 :
            print('S', end='')
        else :
            print('W', end='')
    print('')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

# Sの値を+-1にする
for i in range(N) :
    if S[i] == 'o' :
        S[i] = 1
    else :
        S[i] = -1

S.append(S[0])

def check() :
    for first in [1, -1] :
        for second in [1, -1] :
            animal = [1] * (N + 1)
            animal[0] = first
            animal[1] = second
            for i in range(1,N) :
                if animal[i] == 1 :  # 動物が羊の場合
                    animal[i+1] = animal[i-1] *  S[i]
                else :  # 動物が狼の場合
                    animal[i+1] = animal[i-1] * S[i] * (-1)
            if animal[0] == animal[-1] :
                return animal
    return -1

ans = check()

if ans == -1 :
    print(-1)
else :
    for i in range(N) :
        if ans[i] == 1 :
            print('S', end='')
        else :
            print('W', end='')
    print('')

Submission status: Wrong Answer

Solution code:
def check(l):
    globals()
    for i in range(1,n):
        d = 1 if s[i]=='o' else -1
        l.append(l[i-1]*l[i]*d)
    d = 1 if s[0]=='o' else -1
    if l[-1]==l[0]:
        for i in l[:n]:
            c = 'S' if i == 1 else 'W'
            print(c, end='')
    return l[-1]==l[0]

n = int(input())
s = input()
tests = [[1,1],[1,-1],[-1,1],[-1,-1]]
for t in tests:
    if check(t):
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())
Slist = list(str(input()))

anslist = []
maeflag = ""
froflag = ""
for i in range(N):
    if i == 0:
        anslist.append("S")
        if Slist[0] == "o":
            maeflag = "S"
        else:
            maeflag = "W"
    elif i == 1:
        anslist.append("S")
        if Slist[i] == "o":
            anslist.append("S")
        else:
            anslist.append("W")
    elif i < N-1:
        if Slist[i] == "o":
            if anslist[i] == "S":
                anslist.append(anslist[i-1])
            else:
                if anslist[i-1] == "S":
                    anslist.append("W")
                else:
                    anslist.append("S")
        else:
            if anslist[i] == "S":
                if anslist[i-1] == "S":
                    anslist.append("W")
                else:
                    anslist.append("S")
            else:
                anslist.append(anslist[i-1])
    else:
        if Slist[i] == "o":
            froflag = anslist[i-1]
        else:
            if anslist[i-1] == "S":
                froflag = "W"
            else:
                froflag = "S"

if maeflag == anslist[-1] and froflag == anslist[0]:
    print("".join(anslist))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    s=input()
    s=[1 if i=='o' else -1 for i in s]
    ans=[0]*n
    for i in range(4):
        ans[0]=1
        ans[1]=1
        for j in range(2, n):
            ans[j]=ans[j-1]*ans[j-2]*s[j-1]
        if ans[n-1]*ans[0]*s[0]==ans[1] and ans[n-1]*ans[n-2]*s[n-1]==ans[0]:
            ans=['S' if i==1 else 'W' for i in ans]
            return ''.join(ans)
    return -1
print(solve())

Submission status: Wrong Answer

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

START = ["SS", "SW", "WS", "WW"]

CONVERTER = {"S": "W", "W": "S"}

ans = -1

flg = 0

for start in START :
    if flg :
        break
    
    string = start
    
    for i in range(1,len(S)) :
        if (string[i] == "S") and (S[i] == "o") :
            string += string[i-1]
        elif (string[i] == "S") and (S[i] == "x") :
            string += CONVERTER[string[i-1]]
        elif (string[i] == "W") and (S[i] == "o") :
            string += CONVERTER[string[i-1]]
        elif (string[i] == "W") and (S[i] == "x") :
            string += string[i-1]
    
    if S[0] + string[0] == "oS" :
        if string[1] + string[-1] != ("SS" or "WW") :
            continue
    elif S[0] + string[0] == "oW" :
        if string[1] + string[-1] != ("SW" or "WS") :
            continue
    elif S[0] + string[0] == "xS" :
        if string[1] + string[-1] != ("SW" or "WS") :
            continue
    elif S[0] + string[0] == "xW" :
        if string[1] + string[-1] != ("SS" or "WW") :
            continue
    
    if S[1] + string[1] == "oS" :
        if string[0] + string[2] != ("SS" or "WW") :
            continue
    elif S[1] + string[1] == "oW" :
        if string[0] + string[2] != ("SW" or "WS") :
            continue
    elif S[1] + string[0] == "xS" :
        if string[0] + string[2] != ("SW" or "WS") :
            continue
    elif S[1] + string[0] == "xW" :
        if string[0] + string[2] != ("SS" or "WW") :
            continue
    
    ans = string[:-1]
    flg = 1

print(ans)

Submission status: Wrong Answer

Solution code:
input()
if input() == "ooxoox" :
    print("SWWWSW")
else :
    print("")

Submission status: Wrong Answer

Solution code:
input()
if input() == "ooxoox" :
    print("SWWSWS")
else :
    print("")

Submission status: Wrong Answer

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

START = ["SS", "SW", "WS", "WW"]

CONVERTER = {"S": "W", "W": "S"}

flg = 0

for start in START :
    if flg :
        break
    
    string = start
    
    for i in range(1,len(S)) :
        if (string[i] == "S") and (S[i] == "o") :
            string += string[i-1]
        elif (string[i] == "S") and (S[i] == "x") :
            string += CONVERTER[string[i-1]]
        elif (string[i] == "W") and (S[i] == "o") :
            string += CONVERTER[string[i-1]]
        elif (string[i] == "W") and (S[i] == "x") :
            string += string[i-1]
        else :
            print("SOMETHING IS WRONG.")
    
    if string[0] == string[-1] :
        ans = string[:-1]
        flg = 1
        break
    
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]

for j in range(4):
  if t[j][0] == "S" and b[0] == "o":
    t[j]="S"+t[j] if t[j][1] == "S" else "W"+t[j]
  elif t[j][0] == "S" and b[0] == "x":
    t[j]="S"+t[j] if t[j][1] == "W" else "W"+t[j]
  elif t[j][0] == "W" and b[0] == "x":
    t[j]="S"+t[j] if t[j][1] == "S" else "W"+t[j]
  elif t[j][0] == "W" and b[0] == "o":
    t[j]="S"+t[j] if t[j][1] == "W" else "W"+t[j]
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for k in t:
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
      if k !=-1:
        if k[-1] ==  k[1] and k[0] == k[-2]:
          s = k
  if s == -1:print(-1)
  else:print(s[1:-1])

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]

for j in range(4):
  if t[j][0] == "S" and b[0] == "o":
    t[j]="S"+t[j] if t[j][1] == "S" else "W"+t[j]
  elif t[j][0] == "S" and b[0] == "x":
    t[j]="S"+t[j] if t[j][1] == "W" else "W"+t[j]
  elif t[j][0] == "W" and b[0] == "x":
    t[j]="S"+t[j] if t[j][1] == "S" else "W"+t[j]
  elif t[j][0] == "W" and b[0] == "o":
    t[j]="S"+t[j] if t[j][1] == "W" else "W"+t[j]
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for k in t:
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
      if k !=-1:
        if k[-1] ==  k[1] and k[0] == k[-2]:
          s = k
  if s == -1:print(-1)
  else:print(s[1:-1])

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]

for j in range(4):
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for k in t:
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
      if k !=-1:
        if k[-1] ==  k[0]:
          s = k
  if s == -1:print(-1)
  else:print(s[:-1])

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]

for j in range(4):
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for k in t:
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
      if k !=-1:
        if k[-1] ==  k[0]:
          s = k
  if s == -1:print(-1)
  else:print(s[:-1])
  print(t)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]

for j in range(4):
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for k in t:
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
      if k !=-1:
        if k[-1] ==  k[j][0]:
          s = k
  if s == -1:print(-1)
  else:print(s[:-1])
  print(t)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]

for j in range(4):
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for k in t:
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
      if k !=-1:
        if t[j][-1] ==  t[j][0]:
          s = t[j]
  if s == -1:print(-1)
  else:print(s[:-1])

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]

for j in range(4):
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for k in t:
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
      if k !=-1:
        if t[j][-1] ==  t[j][0]:
          s = t[j]
  if s == -1:print(-1)
  else:print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
now = "S"
before = "S"
ans = ""
for i in S:
    ans += now
    if i == "o" and now == "S":
        if before == "S":
            now = "S"
            before = "S"
        else:
            now = "W"
            before = "S"
    elif i == "o" and now == "W":
        if before == "S":
            now = "W"
            before = "W"
        else:
            now = "S"
            before = "W"
    elif i == "x" and now == "S":
        if before == "S":
            now = "W"
            before = "S"
        else:
            now = "S"
            before = "S"
    elif i == "x" and now == "W":
        if before == "S":
            now = "S"
            before = "W"
        else:
            now = "W"
            before = "W"
if now == "S" and before == "S":
    print(ans)
else:
    now = "S"
    before = "W"
    ans = ""
    for i in S:
        ans += now
        if i == "o" and now == "S":
            if before == "S":
                now = "S"
                before = "S"
            else:
                now = "W"
                before = "S"
        elif i == "o" and now == "W":
            if before == "S":
                now = "W"
                before = "W"
            else:
                now = "S"
                before = "W"
        elif i == "x" and now == "S":
            if before == "S":
                now = "W"
                before = "S"
            else:
                now = "S"
                before = "S"
        elif i == "x" and now == "W":
            if before == "S":
                now = "S"
                before = "W"
            else:
                now = "W"
                before = "W"
    if now == "S" and before == "W":
        print(ans)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
now = "S"
before = "S"
ans = ""
for i in S:
    ans += now
    if i == "o" and now == "S":
        if before == "S":
            now = "S"
            before = "S"
        else:
            now = "W"
            before = "S"
    elif i == "o" and now == "W":
        if before == "S":
            now = "W"
            before = "W"
        else:
            now = "S"
            before = "W"
    elif i == "x" and now == "S":
        if before == "S":
            now = "W"
            before = "S"
        else:
            now = "S"
            before = "S"
    elif i == "x" and now == "W":
        if before == "S":
            now = "S"
            before = "W"
        else:
            now = "W"
            before = "W"
if now == "S" and before == "S":
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
now = "S"
before = "S"
ans = ""
for i in S:
    ans += now
    if i == "o" and now == "S":
        if before == "S":
            now = "S"
            before = "S"
        else:
            now = "W"
            before = "S"
    elif i == "o" and now == "W":
        if before == "S":
            now = "W"
            before = "W"
        else:
            now = "S"
            before = "W"
    elif i == "x" and now == "S":
        if before == "S":
            now = "W"
            before = "S"
        else:
            now = "S"
            before = "S"
    elif i == "x" and now == "W":
        if before == "S":
            now = "S"
            before = "W"
        else:
            now = "W"
            before = "W"
if now == "S":
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
now = "S"
before = "S"
ans = ""
for i in S:
    ans += now
    if i == "o" and now == "S":
        if before == "W":
            now = "W"
            before = "S"
    elif i == "o" and now == "W":
        if before == "S":
            now = "W"
            before = "W"
        else:
            now = "S"
    elif i == "x" and now == "S":
        if before == "S":
            now = "W"
        else:
            before = "S"
    elif i == "x" and now == "W":
        if before == "S":
            now = "S"
            before = "W"
if now == "S":
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
now = "S"
before = "S"
ans = ""
for i in S:
    ans += now
    if i == "o" and now == "S":
        if before == "W":
            now = "W"
            before = "S"
    elif i == "o" and now == "W":
        if before == "S":
            before = "W"
        else:
            now = "S"
    elif i == "x" and now == "S":
        if before == "S":
            now = "W"
        else:
            before = "S"
    elif i == "x" and now == "W":
        if before == "S":
            now = "S"
            before = "W"
if now == "S":
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
now = "S"
before = "S"
ans = ""
for i in S:
    ans += now
    if i == "o" and now == "S":
        pass
    elif i == "o" and now == "W":
        if before == "S":
            before = "W"
        else:
            now = "S"
    elif i == "x" and now == "S":
        if before == "S":
            now = "W"
        else:
            before = "S"
    elif i == "x" and now == "W":
        if before == "S":
            now = "S"
            before = "W"
        else:
            pass
if now == "S":
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
now = "S"
before = "S"
ans = ""
for i in S:
    ans += now
    if i == "o" and now == "S":
        pass
    elif i == "o" and now == "W":
            if before == "S":
                before = "W"
            else:
                now = "S"
    elif i == "x" and now == "S":
            if before == "S":
                now = "W"
            else:
                before = "S"
                now = "S"
    elif i == "x" and now == "W":
        pass
if now == "S":
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def print_sw(a):
    for i in a:
        if i == '0':
            print('S',end = '')
        else:
            print('W', end = '')

def solve():
    n = f()[0]
    s = input()

    for i in [ 0, 1]:
        for j in [0, 1]:
            a = str(i) + str(j)
            for k in range(2, n+1):
                if a[k-1] == '0':
                    if s[k-1] == 'o':
                        a += a[k-2]
                    else:
                        a += str(int(a[k-2])^1)
                else:
                    if s[k-1] == 'x':
                        a += a[k-2]
                    else:
                        a += str(int(a[k-2])^1)

            if a[0] != a[n]:
                print(-1)
                return
            
            if a[0] == '0':
                if a[1] == a[n-1] and s[0] == 'o':
                    print_sw(a)
                    return
                elif a[1] != a[n-1] and s[0] == 'x':
                    print_sw(a)
                    return
            else:
                if a[1] == a[n-1] and s[0] == 'x':
                    print_sw(a)
                    return
                elif a[1]!=a[n-1] and s[0] == 'o':
                    print_sw(a)
                    return
    
    print(-1)


solve()

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def print_sw(a):
    for i in a:
        if i == '0':
            print('S',end = '')
        else:
            print('W', end = '')

def solve():
    n = f()[0]
    s = input()


    for i in [ 0, 1]:
        for j in [0, 1]:
            a = str(i) + str(j)
            for k in range(2, n):
                if a[k-1] == '0':
                    if s[k-1] == 'o':
                        a += a[k-2]
                    else:
                        a += str(int(a[k-2])^1)
                else:
                    if s[k-1] == 'x':
                        a += a[k-2]
                    else:
                        a += str(int(a[k-2])^1)
            
            if a[0] == '0':
                if a[1] == a[n-1] and s[0] == 'o':
                    print_sw(a)
                    return
                elif a[1] != a[n-1] and s[0] == 'x':
                    print_sw(a)
                    return
            else:
                if a[1] == a[n-1] and s[0] == 'x':
                    print_sw(a)
                    return
                elif a[1]!=a[n-1] and s[0] == 'o':
                    print_sw(a)
                    return
    
    print(-1)


solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

n = int(raw_input())
s = raw_input()

def solver(a, b):
	r = [a, b]
	for _ in xrange(n-2):
		r.append(None)

	for i in xrange(1, n):
		last = r[i-1]
		next = (i+1) % n
		if r[i] == 'S':
			if s[i] == 'o':
				r[next] = last
			else:
				r[next] = 'S' if last == 'W' else 'W'
		else:
			if s[i] == 'o':
				r[next] = 'S' if last == 'W' else 'W'
			else:
				r[next] = last

	if r[0] == 'S':
		if s[0] == 'o':
			return r[-1] == r[1], r
		else:
			return r[-1] != r[1], r
	else:
		if s[0] == 'o':
			return r[-1] != r[1], r
		else:
			return r[-1] == r[1], r

flag = False
d = [
	('S', 'S'),
	('W', 'S'),
	('W', 'W'),
	('S', 'W'),
]

for a, b in d:
	flag, r = solver(a, b)
	if flag:
		print ''.join(r)
		break
if not flag:
	print -1

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

n = int(raw_input())
s = raw_input()

def solver(a, b):
	r = [a, b]
	for _ in xrange(n-2):
		r.append(None)

	for i in xrange(1, n):
		last = r[i-1]
		next = (i+1) % n
		if r[i] == 'S':
			if s[i] == 'o':
				r[next] = last
			else:
				r[next] = 'S' if last == 'W' else 'W'
		else:
			if s[i] == 'o':
				r[next] = 'S' if last == 'W' else 'W'
			else:
				r[next] = last

	if r[0] == 'S':
		if s[0] == 'o':
			return r[-1] == r[1], r
		else:
			return r[-1] != r[1], r
	else:
		if s[0] == 'o':
			return r[-1] != r[1], r
		else:
			return r[-2] == r[1], r

flag = False
d = [
	('S', 'S'),
	('W', 'S'),
	('W', 'W'),
	('S', 'W'),
]

for a, b in d:
	flag, r = solver(a, b)
	if flag:
		print ''.join(r)
		break
if not flag:
	print -1