Submission #1259625
Source Code Expand
def check(s, ans, i) : return s[i-1] ^ ans[i-1] ^ ans[i-2] ^ ans[i] def solve(first, second, s) : n = len(s) ans = [0] * (n) ans[-2] = first; ans[-1] = second; for i in range(0, n-2) : nsame = 0 nsame ^= s[i-1] nsame ^= ans[i-1] ans[i] = ans[i-2] ^ nsame if check( s, ans, n-2 ) == 0 and check(s, ans, n-1) == 0 : ans.append(1) # print(ans) return ans N = int(input()) s = input() data = [0] * N for i in range(N) : data[i] = 1 if s[i] == 'x' else 0 ok = 0 for i in range(2) : if ok == 1 : break for j in range(2) : if ok == 1 : break ans = solve(i, j, data) ok = len(ans) - N if ok == 0 : print("-1") else : for i in range(N) : print('W' if ans[i] == 1 else 'S', end = "") print()
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | tokoharu |
Language | Python (3.4.3) |
Score | 500 |
Code Size | 887 Byte |
Status | AC |
Exec Time | 250 ms |
Memory | 6632 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
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 | 18 ms | 3064 KB |
00_example_02.txt | AC | 18 ms | 3064 KB |
00_example_03.txt | AC | 18 ms | 3064 KB |
01.txt | AC | 183 ms | 6028 KB |
02.txt | AC | 90 ms | 5364 KB |
03.txt | AC | 21 ms | 3064 KB |
04.txt | AC | 18 ms | 3064 KB |
05.txt | AC | 244 ms | 6632 KB |
06.txt | AC | 152 ms | 6132 KB |
07.txt | AC | 48 ms | 4852 KB |
08.txt | AC | 46 ms | 4724 KB |
09.txt | AC | 28 ms | 3828 KB |
10.txt | AC | 48 ms | 3572 KB |
11.txt | AC | 242 ms | 6224 KB |
12.txt | AC | 250 ms | 6224 KB |
13.txt | AC | 206 ms | 6240 KB |