Submission #1479615
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 | 0 |
Code Size | 1605 Byte |
Status | WA |
Exec Time | 113 ms |
Memory | 6956 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 11 ms | 2824 KB |
00_example_02.txt | AC | 11 ms | 2824 KB |
00_example_03.txt | WA | 11 ms | 2824 KB |
01.txt | WA | 64 ms | 5452 KB |
02.txt | WA | 32 ms | 4660 KB |
03.txt | AC | 12 ms | 2824 KB |
04.txt | WA | 11 ms | 2824 KB |
05.txt | WA | 87 ms | 6516 KB |
06.txt | WA | 52 ms | 6532 KB |
07.txt | WA | 24 ms | 3588 KB |
08.txt | WA | 21 ms | 3460 KB |
09.txt | WA | 13 ms | 2948 KB |
10.txt | AC | 26 ms | 3588 KB |
11.txt | WA | 113 ms | 6928 KB |
12.txt | WA | 113 ms | 6928 KB |
13.txt | WA | 95 ms | 6956 KB |