Submission #1272054


Source Code Expand

N = int(raw_input())
s = raw_input()
# 0: S, 1: W

def init():
    if s[0] == 'o':
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 1, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 0, 0
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 0, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 1, 0
        yield v
    else:
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 0, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 1, 0
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 1, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 0, 0
        yield v

def run():
    ok = False
    for v in init():
        ok = True
        for i in range(1, N):
            if s[i] == 'o':
                if v[i] == 0:
                    nv = v[i-1]
                else:
                    nv = 1-v[i-1]
            else:
                if v[i] == 0:
                    nv = 1-v[i-1]
                else:
                    nv = v[i-1]
            ni = (i+1) % N
            if (v[ni] > -1) and (v[ni] != nv):
                ok = False
                break
            v[ni] = nv 
        if ok:
            return ''.join(['S' if _ == 0 else 'W' for _ in v])
    return "-1"

print run()

Submission Info

Submission Time
Task D - Menagerie
User namakemono
Language Python (2.7.6)
Score 500
Code Size 1485 Byte
Status AC
Exec Time 141 ms
Memory 7540 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 11 ms 2820 KB
00_example_02.txt AC 11 ms 2820 KB
00_example_03.txt AC 11 ms 2820 KB
01.txt AC 74 ms 5788 KB
02.txt AC 28 ms 4696 KB
03.txt AC 14 ms 2820 KB
04.txt AC 11 ms 2732 KB
05.txt AC 101 ms 7164 KB
06.txt AC 73 ms 7100 KB
07.txt AC 26 ms 3460 KB
08.txt AC 22 ms 3712 KB
09.txt AC 12 ms 2948 KB
10.txt AC 35 ms 3692 KB
11.txt AC 141 ms 7540 KB
12.txt AC 141 ms 7540 KB
13.txt AC 110 ms 7540 KB