Submission #1117069
Source Code Expand
from collections import defaultdict def solve(s, l): for i in range(1, len(s) - 1): # ひつじ if l[i] == 1: if s[i] == "o": l[i + 1] = l[i - 1] else: l[i + 1] = -1 * l[i - 1] # おおかみ else: if s[i] == "o": l[i + 1] = -1 * l[i - 1] else: l[i + 1] = l[i - 1] if l[0] == 1: if s[0] == "o": ok1 = l[1] == l[-1] else: ok1 = l[1] != l[-1] # おおかみ else: if s[0] == "o": ok1 = l[1] != l[-1] else: ok1 = l[1] == l[-1] if l[-1] == 1: if s[-1] == "o": ok2 = l[0] == l[-2] else: ok2 = l[0] != l[-2] # おおかみ else: if s[-1] == "o": ok2 = l[0] != l[-2] else: ok2 = l[0] == l[-2] return ok1 and ok2 def main(): N = int(input()) S = input() ans = [None] * N ans[0] = 1 ans[1] = 1 if solve(S, ans): print(*["S" if x == 1 else "W" for x in ans], sep="") return ans = [None] * N ans[0] = 1 ans[1] = -1 if solve(S, ans): print(*["S" if x == 1 else "W" for x in ans], sep="") return ans = [None] * N ans[0] = -1 ans[1] = 1 if solve(S, ans): print(*["S" if x == 1 else "W" for x in ans], sep="") return ans = [None] * N ans[0] = -1 ans[1] = -1 if solve(S, ans): print(*["S" if x == 1 else "W" for x in ans], sep="") return print(-1) if __name__ == '__main__': main()
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | MitI_7 |
Language | Python (3.4.3) |
Score | 500 |
Code Size | 1659 Byte |
Status | AC |
Exec Time | 139 ms |
Memory | 7876 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 | 20 ms | 3316 KB |
00_example_02.txt | AC | 20 ms | 3316 KB |
00_example_03.txt | AC | 20 ms | 3316 KB |
01.txt | AC | 83 ms | 6536 KB |
02.txt | AC | 46 ms | 6024 KB |
03.txt | AC | 22 ms | 3316 KB |
04.txt | AC | 20 ms | 3316 KB |
05.txt | AC | 108 ms | 7016 KB |
06.txt | AC | 70 ms | 7088 KB |
07.txt | AC | 36 ms | 5236 KB |
08.txt | AC | 34 ms | 5104 KB |
09.txt | AC | 23 ms | 4084 KB |
10.txt | AC | 37 ms | 3700 KB |
11.txt | AC | 139 ms | 7876 KB |
12.txt | AC | 139 ms | 7876 KB |
13.txt | AC | 118 ms | 7252 KB |