Submission #2831513


Source Code Expand

from itertools import product

N = int(input())
S = input()


def r(x):
    if x == 'S':
        return 'W'
    else:
        return 'S'


def f(x1, x2, s):
    if s == 'o':
        if x1 == 'S':
            return x2
        else:
            return r(x2)
    else:
        if x1 == 'S':
            return r(x2)
        else:
            return x2


ans = ['-1']
for x1, x2 in product('SW', repeat=2):
    res = [x1, x2]
    for i in range(N):
        x1, x2 = x2, f(x1, x2, S[i])
        res.append(x2)
    if res[:2] == res[-2:]:
        ans = res[1:-1]
        break
print(''.join(ans))

Submission Info

Submission Time
Task D - Menagerie
User xkumiyu
Language Python (3.4.3)
Score 500
Code Size 628 Byte
Status AC
Exec Time 195 ms
Memory 4964 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 16
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 17 ms 3064 KB
00_example_02.txt AC 17 ms 3064 KB
00_example_03.txt AC 18 ms 3064 KB
01.txt AC 150 ms 4300 KB
02.txt AC 41 ms 4012 KB
03.txt AC 22 ms 3064 KB
04.txt AC 18 ms 3064 KB
05.txt AC 180 ms 4784 KB
06.txt AC 61 ms 4748 KB
07.txt AC 45 ms 3316 KB
08.txt AC 25 ms 3316 KB
09.txt AC 23 ms 3064 KB
10.txt AC 54 ms 3288 KB
11.txt AC 110 ms 4964 KB
12.txt AC 107 ms 4964 KB
13.txt AC 195 ms 4964 KB