Submission #1117093


Source Code Expand

n = int(input())
s = input()

sw = [1,0]
ss = [1,1]
ws = [0,1]
ww = [0,0]

def nxt(tf, last):
    if tf=='x' and last=='S':
        return ''

for idx,c in enumerate(s):
    if idx==0:
        continue
    if c == 'x':
        sw.append(sw[-1]^sw[-2])
        ss.append(ss[-1]^ss[-2])
        ws.append(ws[-1]^ws[-2])
        ww.append(ww[-1]^ww[-2])
    else:
        sw.append(1*(not(sw[-1]^sw[-2])))
        ss.append(1*(not(ss[-1]^ss[-2])))
        ws.append(1*(not(ws[-1]^ws[-2])))
        ww.append(1*(not(ww[-1]^ww[-2])))

c=s[0]
if c == 'x':
    sw.append(sw[-1]^sw[-2])
    ss.append(ss[-1]^ss[-2])
    ws.append(ws[-1]^ws[-2])
    ww.append(ww[-1]^ww[-2])
else:
    sw.append(1*(not(sw[-1]^sw[-2])))
    ss.append(1*(not(ss[-1]^ss[-2])))
    ws.append(1*(not(ws[-1]^ws[-2])))
    ww.append(1*(not(ww[-1]^ww[-2])))


def f(seq):
    # print(seq[-1],seq[0])
    return seq[-2:]==seq[:2]

def pp(seq):
    print(''.join(map(lambda x:'S' if x else 'W', seq[:-2])))

if f(sw):
    pp(sw)
elif f(ss):
    pp(ss)
elif f(ws):
    pp(ws)
elif f(ww):
    pp(ww)
else:
    print(-1)

Submission Info

Submission Time
Task D - Menagerie
User coricozizi
Language Python (3.4.3)
Score 500
Code Size 1138 Byte
Status AC
Exec Time 127 ms
Memory 8256 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 3188 KB
00_example_02.txt AC 17 ms 3192 KB
00_example_03.txt AC 18 ms 3188 KB
01.txt AC 92 ms 6440 KB
02.txt AC 66 ms 5604 KB
03.txt AC 20 ms 3188 KB
04.txt AC 18 ms 3188 KB
05.txt AC 110 ms 7560 KB
06.txt AC 117 ms 7532 KB
07.txt AC 34 ms 4084 KB
08.txt AC 36 ms 4036 KB
09.txt AC 22 ms 3316 KB
10.txt AC 37 ms 4036 KB
11.txt AC 127 ms 8256 KB
12.txt AC 126 ms 8048 KB
13.txt AC 125 ms 8000 KB