Submission #1479692
Source Code Expand
def menagerie_2(): n = int(raw_input()) ans = str(raw_input()) def check_possibility(at, a): re = ['#']*len(a) re[0] = at[0] re[1] = at[1] for i in range(1, n-1): if a[i]=='o': if re[i]==1: re[i+1] = re[i-1] else: re[i+1] = re[i-1]*-1 else: if re[i]==1: re[i+1] = re[i-1]*-1 else: re[i+1] = re[i-1] c1 = False c2 = False if a[0]=='o': if re[0]==1 and (re[1]*re[-1]==1): c1 = True elif re[0]==-1 and (re[1]*re[-1]==-1): c1 = True else: if re[0]==1 and (re[1]*re[-1]==-1): c1 = True elif re[0]==-1 and (re[1]*re[-1]==1): c1 = True if a[-1]=='o': if re[-1]==1 and (re[0]*re[-2]==1): c2 = True elif re[-1]==-1 and (re[0]*re[-2]==-1): c2 = True else: if re[-1]==1 and (re[0]*re[-2]==-1): c2 = True elif re[-1]==-1 and (re[0]*re[-2]==1): c2 = True if c1 and c2: return re else: return None if check_possibility([1,1], ans) is not None: op = ['S' if x == 1 else 'W' for x in check_possibility([1,1], ans)] print''.join(op) elif check_possibility([1,-1], ans) is not None: op = ['S' if x == 1 else 'W' for x in check_possibility([1,-1], ans)] print''.join(op) elif check_possibility([-1,1], ans) is not None: op = ['S' if x == 1 else 'W' for x in check_possibility([-1,1], ans)] print''.join(op) elif check_possibility([-1,-1], ans) is not None: op = ['S' if x == 1 else 'W' for x in check_possibility([-1,-1], ans)] print''.join(op) else: print -1 if __name__ == "__main__": menagerie_2()
Submission Info
Submission Time | |
---|---|
Task | D - Menagerie |
User | zhuang |
Language | Python (2.7.6) |
Score | 500 |
Code Size | 1605 Byte |
Status | AC |
Exec Time | 115 ms |
Memory | 6956 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 | 11 ms | 2824 KB |
00_example_02.txt | AC | 11 ms | 2824 KB |
00_example_03.txt | AC | 11 ms | 2824 KB |
01.txt | AC | 65 ms | 5452 KB |
02.txt | AC | 32 ms | 4660 KB |
03.txt | AC | 13 ms | 2824 KB |
04.txt | AC | 11 ms | 2824 KB |
05.txt | AC | 87 ms | 6516 KB |
06.txt | AC | 52 ms | 6532 KB |
07.txt | AC | 24 ms | 3460 KB |
08.txt | AC | 22 ms | 3460 KB |
09.txt | AC | 13 ms | 2948 KB |
10.txt | AC | 26 ms | 3588 KB |
11.txt | AC | 114 ms | 6928 KB |
12.txt | AC | 115 ms | 6928 KB |
13.txt | AC | 95 ms | 6956 KB |