Submission #1372991
Source Code Expand
import sys # sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(input()) def read_str(): return input() def solve(n, r): for a0 in range(2): for a1 in range(2): a = [a0, a1] + [-1] * (n - 2) for i in range(2, n): if r[i - 1] == 'o': t = a[i - 2] else: t = 1 - a[i - 2] if a[i - 1] == 1: t = 1 - t a[i] = t ok = True for i in range(-1, n - 1): if a[i - 1] != a[i + 1]: s = 1 else: s = 0 if a[i] == 1: s = 1 - s if s == 1: expected = 'x' else: expected = 'o' ok &= r[i] == expected if ok: l = map(lambda j: 'SW'[j], a) res = ''.join(l) return res return -1 def main(): n = read_int() r = read_str() res = solve(n, r) print(res) main()
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | xiaodidi |
Language | Python (3.4.3) |
Score | 500 |
Code Size | 1293 Byte |
Status | AC |
Exec Time | 274 ms |
Memory | 5588 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 | 17 ms | 3064 KB |
00_example_02.txt | AC | 17 ms | 3064 KB |
00_example_03.txt | AC | 17 ms | 3064 KB |
01.txt | AC | 142 ms | 4748 KB |
02.txt | AC | 51 ms | 3980 KB |
03.txt | AC | 23 ms | 3064 KB |
04.txt | AC | 18 ms | 3064 KB |
05.txt | AC | 193 ms | 5356 KB |
06.txt | AC | 82 ms | 4660 KB |
07.txt | AC | 47 ms | 3572 KB |
08.txt | AC | 40 ms | 3440 KB |
09.txt | AC | 20 ms | 3188 KB |
10.txt | AC | 66 ms | 3548 KB |
11.txt | AC | 274 ms | 5476 KB |
12.txt | AC | 274 ms | 5476 KB |
13.txt | AC | 210 ms | 5588 KB |