s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s901008286
p03798
u815878613
1574772111
Python
Python (3.4.3)
py
Runtime Error
45
4752
919
import sys readline = sys.stdin.buffer.readline def main(): N = int(input()) s = readline() s = list(s.decode('UTF-8').rstrip("\n")) s.append(s[0]) s.insert(0, s[-2]) init = ((1, 1), (0, 1), (1, 0), (0, 0)) # init = ((0, 0), (0, 1), (1, 0), (1, 1)) for i in init: p = [0] * (N+2) p[0] = i[0] p[1] = i[1] for j in range(1, N+1): if s[j] == "o": if p[j] == 0: p[j+1] = p[j-1] ^ p[j] else: p[j+1] = p[j-1] ^ 1 else: if p[j] == 0: p[j+1] = p[j-1] ^ 1 else: p[j+1] = p[j-1] ^ p[j] if p[0] == p[-2] and p[1] == p[-1]: ss = list(map(lambda x: "W" if x == 1 else "S", p[1:N+1])) print(''.join(ss)) sys.exit() else: print(-1) main()
s366775737
p03798
u091051505
1568250858
Python
Python (3.4.3)
py
Runtime Error
17
3064
1177
n = int(input()) s = input() pattern = ["SS", "SW", "WS", "WW"] dict_s = {"S":"W", "W":"S"} not_clear = True for p in pattern: ans = p for i in range(1, n - 1): if s[i] == "o": if ans[i] == "W": ans += dict_s[ans[i-1]] else: ans += ans[i-1] else: if ans[i] == "S": ans += dict_s[ans[i-1]] else: ans += ans[i-1] if s[n - 1] == "o": if ans[n - 1] == "S": if ans[0] == ans[n - 2]: print(ans) exit() else: continue else: if ans[0] != ans[n - 2]: print(ans) exit() else: continue else: continue if s[n - 1] == "x": if ans[n - 1] == "W": if ans[0] == ans[n - 2]: print(ans) exit() else: continue else: if ans[0] != ans[n - 2]: print(ans) exit() else: continue if not_clear: print(-1)
s422829837
p03798
u903082918
1565723668
Python
Python (3.4.3)
py
Runtime Error
18
3060
291
""" abc055_a """ import sys H = pow(10, 9) + 7 def _main(): n_s, n_c = map(int, sys.stdin.readline().split(' ')) if 2 * n_s <= n_c: result = n_s + int((n_c - n_s * 2) / 4) else: result = int(n_c / 2) print(result) if __name__ == '__main__': _main()
s331470676
p03798
u483645888
1559683685
Python
Python (3.4.3)
py
Runtime Error
1797
3836
272
n = int(input()) s = input() l = ['SS','WS','SW','WW'] for i in range(n): for j in range(len(l)): l[j] += 'SW'[::-1 if s[i]=='o' else 1][l[j][i]==l[j][i+1]] for i in range(n): if l[i][1]==l[i][n+1] and l[i][0]==l[i][n]: print(l[i][1:n+1]) exit() print(-1)
s318174315
p03798
u059210959
1558653932
Python
Python (3.4.3)
py
Runtime Error
17
2940
810
n = int(input()) s = [1 if si == 'o' else 0 for si in list(input())] t0 = [[1, 1], [1, 0], [0, 1], [0, 0]] for ti in t0: flag = True for i in range(1, n - 1): if ti[i] * (1 - s[i]) or (1 - ti[i]) * s[i]: ti.append(1 - ti[i - 1]) else: ti.append(ti[i - 1]) for i in range(2): if ti[i - 1]: if (s[i - 1] and not ti[i - 2] == ti[i]) or (1 - s[i - 1] and ti[i - 2] == ti[i]): flag = False else: if (s[i - 1] and ti[i - 2] == ti[i]) or (1 - s[i - 1] and not ti[i - 2] == ti[i]): flag = False if flag: ans = ['S' if x else 'W' for x in ti] print(''.join(ans)) exit() print(-1)
s683694809
p03798
u059210959
1558653898
Python
Python (3.4.3)
py
Runtime Error
17
3064
705
s = [1 if si == 'o' else 0 for si in list(input())] t0 = [[1, 1], [1, 0], [0, 1], [0, 0]] for ti in t0: flag = True for i in range(1, n - 1): if ti[i] * (1 - s[i]) or (1 - ti[i]) * s[i]: ti.append(1 - ti[i - 1]) else: ti.append(ti[i - 1]) for i in range(2): if ti[i - 1]: if (s[i - 1] and not ti[i - 2] == ti[i]) or (1 - s[i - 1] and ti[i - 2] == ti[i]): flag = False else: if (s[i - 1] and ti[i - 2] == ti[i]) or (1 - s[i - 1] and not ti[i - 2] == ti[i]): flag = False if flag: ans = ['S' if x else 'W' for x in ti] print(''.join(ans)) exit() print(-1)
s962212607
p03798
u573272932
1558063627
Python
Python (3.4.3)
py
Runtime Error
17
3064
336
inputa = int(input()) inputb = input() flag = 0 res = "" for c in inputb: if c == "o": if flag % 2 == 0: res += "S" else: res += "W" else: res += "S" flag += 1 if inputb[0] == "o": if flag % 2 != 0: print(-1) return if inputb[0] == "x": if flag % 2 != 1: print(-1) return print(res)
s409862959
p03798
u318861481
1537322474
Python
Python (3.4.3)
py
Runtime Error
17
3064
510
from itertools import product N = int(input()) S = [0 if i == 'o' else 1 for i in input()] for i, j in product(range(2), repeat=2): pattern = [i, j] + [0] * (N - 2) for k in range(2, N): pattern[k] = ( S[k-1] - (pattern[k - 1] + pattern[k - 2] )) % 2 if S[-1] != (pattern[-2] + pattern[-1] + pattern[0]) % 2 : continue if S[0] != (pattern[-1] + pattern[0] + pattern[1]) % 2 : continue answer = [ 'S' if pattern[k] == 0 else 'W' for k in range(N)] print(''.join(answer)) return None print(-1)
s087287677
p03798
u318861481
1537322424
Python
Python (3.4.3)
py
Runtime Error
17
3064
510
from itertools import product N = int(input()) S = [0 if i == 'o' else 1 for i in input()] for i, j in product(range(2), repeat=2): pattern = [i, j] + [0] * (N - 2) for k in range(2, N): pattern[k] = ( S[k-1] - (pattern[k - 1] + pattern[k - 2] )) % 2 if S[-1] != (pattern[-2] + pattern[-1] + pattern[0]) % 2 : continue if S[0] != (pattern[-1] + pattern[0] + pattern[1]) % 2 : continue answer = [ 'S' if pattern[k] == 0 else 'W' for k in range(N)] print(''.join(answer)) return None print(-1)
s174342321
p03798
u318861481
1537322132
Python
Python (3.4.3)
py
Runtime Error
17
2940
590
!/usr/bin/python3 from itertools import product def solve(): N = int(input()) S = [0 if i == 'o' else 1 for i in input()] for i, j in product(range(2), repeat=2): pattern = [i, j] + [0] * (N - 2) for k in range(2, N): pattern[k] = (pattern[k - 1] + pattern[k - 2] + S[k] ) % 2 if S[-1] != (pattern[-2] + pattern[-1] + pattern[0]) % 2 : continue if S[0] != (pattern[-1] + pattern[0] + pattern[1]) % 2 : continue answer = [ 'S' if pattern[k] == 0 else 'W' for k in range(N)] print(''.join(answer)) return None print(-1) if __name__ == '__main__': solve()
s392044133
p03798
u318861481
1537322039
Python
Python (3.4.3)
py
Runtime Error
17
2940
589
!/usr/bin/python3 from itertools import product def solve(): N = int(input()) S = [0 if i == 'o' else 1 for i in input()] for i, j in product(range(2), repeat=2): pattern = [i, j] + [0] * (N - 2) for k in range(2, N): pattern[k] = (pattern[k - 1] + pattern[k - 2] + S[k] ) % 2 if S[-1] != (pattern[-2] + pattern[-1] + pattern[0]) % 2 : continue if S[0] != (pattern[-1] + pattern[0] + pattern[1]) % 2 : continue answer = [ 'S' if pattern[k] == 0 else 'W' for k in range(N)] print(''.join(answer)) return None; print(-1); if __name__ == '__main__': solve()
s222567144
p03798
u318861481
1537321960
Python
Python (3.4.3)
py
Runtime Error
23
4092
575
def solve(): N = int(input()) S = [0 if i == 'o' else 1 for i in input()] for i, j in product(range(2), repeat=2): pat = [i, j] + [0]*(N - 2) for k in range(2, N): pat[k] = (S[k - 1] - (pat[k - 1] + pat[k - 2])) % 2 if S[-1] != (pat[0] + pat[-1] + pat[-2]) % 2: continue if S[0] != (pat[1] + pat[0] + pat[-1]) % 2: continue ans = ['S' if pat[k] == 0 else 'W' for k in range(N)] print(''.join(ans)) return None print(-1) if __name__ == '__main__': solve()
s379464328
p03798
u318861481
1537321887
Python
Python (3.4.3)
py
Runtime Error
23
3996
575
def solve(): N = int(input()) S = [0 if i == 'o' else 1 for i in input()] for i, j in product(range(2), repeat=2): pat = [i, j] + [0]*(N - 2) for k in range(2, N): pat[k] = (S[k - 1] - (pat[k - 1] + pat[k - 2])) % 2 if S[-1] != (pat[0] + pat[-1] + pat[-2]) % 2: continue if S[0] != (pat[1] + pat[0] + pat[-1]) % 2: continue ans = ['S' if pat[k] == 0 else 'W' for k in range(N)] print(''.join(ans)) return None print(-1) if __name__ == '__main__': solve()
s303883115
p03798
u648901783
1536175197
Python
Python (3.4.3)
py
Runtime Error
92
5016
2511
n = int(input()) s = input() animal = [0]*n #0が羊、1が狼 f = [False] def dfs(v,animal): if f[0]== True: return if v == n-1: if s[v]=='o': if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return else: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return else: if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return else: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return if f[0]==False: # print("False!") return if s[v]=='o': if animal[v]==0: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v]==0: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) dfs(0,animal) animal1 = animal f1 = f[0] animal = [0]*n #0が羊、1が狼 f = [False] dfs(1,animal) animal2 = animal f2 = f[0] if (f1==False) and (f2==False): print(-1) if f1 == True: u = '' for i in range(0,n): if animal1[i]==0: u = u+'S' else: u = u + 'W' print(u) if (f1 != True) and (f2 ==True): u = '' for i in range(0,n): if animal2[i]==0: u = u+'S' else: u = u + 'W' print(u)
s601507782
p03798
u648901783
1536174430
Python
Python (3.4.3)
py
Runtime Error
97
5008
2296
n = int(input()) s = input() animal = [0]*n #0が羊、1が狼 f = [False] def dfs(v,animal): if v == 0: dfs(1,animal) animal[0]+=1 dfs(1,animal) if f[0]== True: return if v == n-1: if s[v]=='o': if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return else: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return else: if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return else: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return if f[0]==False: # print("False!") return if s[v]=='o': if animal[v]==0: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v]==0: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) dfs(0,animal) if f[0]==False: print(-1) if f[0]==True: u = '' for i in range(0,n): if animal[i]==0: u = u+'S' else: u = u + 'W' print(u)
s890462209
p03798
u648901783
1536174360
Python
Python (3.4.3)
py
Runtime Error
93
5000
2302
n = int(input()) s = input() animal = [0]*n #0が羊、1が狼 f = [False] def dfs(v,animal): if v == 0: dfs(1,animal) animal[0]+=1 dfs(1,animal) if f[0]== True: return animal if v == n-1: if s[v]=='o': if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return else: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return else: if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return else: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return if f[0]==False: # print("False!") return if s[v]=='o': if animal[v]==0: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v]==0: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) dfs(0,animal) if f[0]==False: print(-1) if f[0]==True: u = '' for i in range(0,n): if animal[i]==0: u = u+'S' else: u = u + 'W' print(u)
s279809302
p03798
u648901783
1536174246
Python
Python (3.4.3)
py
Runtime Error
94
5008
2327
n = int(input()) s = input() animal = [0]*n #0が羊、1が狼 f = [False] def dfs(v,animal): if v == 0: dfs(1,animal) animal[0]+=1 dfs(1,animal) if f[0]== True: return animal if v == n-1: if s[v]=='o': if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return animal else: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return animal else: if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return animal else: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return animal if f[0]==False: # print("False!") return if s[v]=='o': if animal[v]==0: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v]==0: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) dfs(0,animal) if f[0]==False: print(-1) if f[0]==True: u = '' for i in range(0,n): if animal[i]==0: u = u+'S' else: u = u + 'W' print(u)
s486899241
p03798
u648901783
1536173784
Python
Python (3.4.3)
py
Runtime Error
97
5008
2229
n = int(input()) s = input() animal = [0]*n #0が羊、1が狼 f = [False] def dfs(v,animal): if f[0]== True: return animal if v == n-1: if s[v]=='o': if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return animal else: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return animal else: if animal[v]==0: if ((animal[v-1]==0)and(animal[0]==1))or((animal[v-1]==1)and(animal[0]==0)): # print("True!") f[0]= True return animal else: if ((animal[v-1]==0)and(animal[0]==0))or((animal[v-1]==1)and(animal[0]==1)): # print("True!") f[0]= True return animal if f[0]==False: # print("False!") return if s[v]=='o': if animal[v]==0: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v]==0: if animal[v-1]==0: animal[v+1]+=1 dfs(v+1,animal) else: animal[v+1]=0 dfs(v+1,animal) else: if animal[v-1]==0: animal[v+1]=0 dfs(v+1,animal) else: animal[v+1]+=1 dfs(v+1,animal) dfs(0,animal) if f[0]==False: print(-1) if f[0]==True: u = '' for i in range(0,n): if animal[i]==0: u = u+'S' else: u = u + 'W' print(u)
s423820750
p03798
u334712262
1534329900
Python
Python (3.4.3)
py
Runtime Error
136
7368
4198
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(10000) # -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(10000) def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap @mt def slv(N, S): def f(cnd): for i in range(1, N): if S[i] == 'o' and cnd[i] == 'S': cnd.append(cnd[i-1]) elif S[i] == 'o' and cnd[i] == 'W': cnd.append('S' if cnd[i-1] == 'W' else 'W') elif S[i] == 'x' and cnd[i] == 'S': cnd.append('S' if cnd[i-1] == 'W' else 'W') elif S[i] == 'x' and cnd[i] == 'W': cnd.append(cnd[i-1]) if cnd[0] != cnd[-1]: return None if cnd[0] == 'S' and S[0] == 'o' and cnd[1] == cnd[-1]: return ''.join(cnd[:-1]) elif cnd[0] == 'S' and S[0] == 'x' and cnd[1] != cnd[-1]: return ''.join(cnd[:-1]) elif cnd[0] == 'W' and S[0] == 'o' and cnd[1] != cnd[-1]: return ''.join(cnd[:-1]) elif cnd[0] == 'W' and S[0] == 'x' and cnd[1] == cnd[-1]: return ''.join(cnd[:-1]) return None # SS ans = f(['S', 'S']) if ans: return ans # SW ans = f(['S', 'W']) if ans: return ans # WS ans = f(['W', 'S']) if ans: return ans # WW ans = f(['W', 'W']) if ans: return ans return -1 def main(): N = read_int() S = read_str() print(slv(N, S)) if __name__ == '__main__': main() def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap @mt def slv(N, S): def f(cnd): for i in range(1, N): if S[i] == 'o' and cnd[i] == 'S': cnd.append(cnd[i-1]) elif S[i] == 'o' and cnd[i] == 'W': cnd.append('S' if cnd[i-1] == 'W' else 'W') elif S[i] == 'x' and cnd[i] == 'S': cnd.append('S' if cnd[i-1] == 'W' else 'W') elif S[i] == 'x' and cnd[i] == 'W': cnd.append(cnd[i-1]) if cnd[0] == cnd[-1]: return ''.join(cnd[:-1]) return None ans = f(['S', 'S']) if ans: return ans ans = f(['S', 'W']) if ans: return ans ans = f(['W', 'S']) if ans: return ans ans = f(['W', 'W']) if ans: return ans return -1 def main(): N = read_int() S = read_str() print(slv(N, S)) if __name__ == '__main__': main()
s087759703
p03798
u118642796
1526378890
Python
Python (3.4.3)
py
Runtime Error
76
4528
452
N = int(input()) s = input() def DFS(ans): if len(ans) == N+2: return ans if (ans[-1] == "S") ^ (s[len(ans)-2] == "o") ^ (ans[-2] == "W"): ans += "W" else: ans += "S" return DFS(ans) for initial in ["SS","SW","WS","WW"]: ans = DFS(initial) if ans[0] == ans[-2] and ans[1] == ans[-1]: print(ans[1:-1]) exit() print("-1")
s264790444
p03798
u952708174
1524601105
Python
Python (3.4.3)
py
Runtime Error
17
3188
1070
def d_menagerie(N, S): s = S + S[0:2] # 円環状に並んでいることを考慮 for ans in ['SS', 'SW', 'WS', 'WW']: # Sは羊、Wは狼。1番と2番の種類を仮定する for i in range(1, N + 1): if (ans[-1] == 'S' and s[i] == 'o') or (ans[-1] == 'W' and s[i] == 'x'): # この場合、今注目している動物の両隣は同じ種類。 # よって、今注目している動物の右隣を左隣と同じにする。 ans += ans[-2] else: # 両隣は違う種類。右隣を左隣と逆にする。 ans += ('S' if ans[-2] == 'W' else 'W') if ans[:2] == ans[N:]: # sの最初の2文字(仮定)と最後の2文字が一致した文字列のみ受理する。 # 1つ見つければ良いので、すぐにbreakする ans = ans[:N] break else: # どの割り当て方も矛盾した ans = '-1' return ans N = int(input()) S = input().strip() print(d_Menagerie(N, S))
s326010474
p03798
u391475811
1523042240
Python
Python (3.4.3)
py
Runtime Error
2438
2053012
753
import sys sys.setrecursionlimit(100001) N=int(input()) S=input() def solve(n,str): if n==N: if str[-2]==str[0] and str[-1]==str[1]: str=str[1:-1] else: str="" return str else: if (S[n]=="o" and str[-1]=="S") or (S[n]=="x" and str[-1]=="W"): str=str+str[-2] else: if str[-2]=="W": str=str+"S" else: str=str+"W" ans=solve(n+1,str) return ans flgT=["SSS","SWW","WWS","WSW"] flgF=["SSW","WSS","SWS","WWW"] imp=True if S[0]=='o': for i in range(4): ans=solve(1,flgT[i]) if len(ans)>0: print(ans) imp=False break else: for i in range(4): ans=solve(1,flgF[i]) if len(ans)>0: print(ans) imp=False break if imp: print(-1)
s728553178
p03798
u391475811
1523041920
Python
Python (3.4.3)
py
Runtime Error
79
4728
710
N=int(input()) S=input() def solve(n,str): if n==N: if str[-2]==str[0] and str[-1]==str[1]: str=str[1:-1] else: str="" return str else: if (S[n]=="o" and str[-1]=="S") or (S[n]=="x" and str[-1]=="W"): str=str+str[-2] else: if str[-2]=="W": str=str+"S" else: str=str+"W" ans=solve(n+1,str) return ans flgT=["SSS","SWW","WWS","WSW"] flgF=["SSW","WSS","SWS","WWW"] imp=True if S[0]=='o': for i in range(4): ans=solve(1,flgT[i]) if len(ans)>0: print(ans) imp=False break else: for i in range(4): ans=solve(1,flgF[i]) if len(ans)>0: print(ans) imp=False break if imp: print(-1)
s144758103
p03798
u018679195
1512598576
Python
Python (3.4.3)
py
Runtime Error
376
7020
2700
#!/usr/bin/env python3 n = int(input()) s = input() t1 = ["S","S"] l1 = ["W","W"] t2 = ["S","W"] l2 = ["W","S"] for i in range(n-2): t1.append("S") for i in range(n): if i+1 <= n-1 and i != 0: if (s[i] == "x" and t1[i] == "S") or (s[i] == "o" and t1[i] == "W"): if t1[i-1] == "S": t1[i+1] = "W" else: t1[i+1] = "S" else: t1[i+1] = t1[i] elif i == 0: pass else: if ((s[i] == "x" and t1[i] == "S") or (s[i] == "o" and t1[i] == "W")) and t1[0] == t1[i-1]: t1 = "-1" elif ((s[i] == "x" and t1[i] == "W") or (s[i] == "o" and t1[i] == "S")) and t1[0] != t1[i-1]: t1 = "-1" for i in range(n-2): t2.append("S") for i in range(n): if i+1 <= n-1 and i != 0: if (s[i] == "x" and t2[i] == "S") or (s[i] == "o" and t2[i] == "W"): if t2[i-1] == "S": t2[i+1] = "W" else: t2[i+1] = "S" else: t2[i+1] = t2[i] elif i == 0: pass else: if ((s[i] == "x" and t2[i] == "S") or (s[i] == "o" and t2[i] == "W")) and t2[0] == t2[i-1]: t = "-1" elif ((s[i] == "x" and t2[i] == "W") or (s[i] == "o" and t2[i] == "S")) and t2[0] != t2[i-1]: t = "-1" for i in range(n-2): l1.append("W") for i in range(n): if i+1 <= n-1 and i != 0: if (s[i] == "x" and l1[i] == "S") or (s[i] == "o" and l1[i] == "W"): if l1[i-1] == "S": l1[i+1] = "W" else: l1[i+1] = "S" else: l1[i+1] = l1[i] elif i == 0: pass else: if(s[i] == "x" and l1[i] == "S") or (s[i] == "o" and l1[i] == "W") and l1[0] == l1[i-1]: l1 = "-1" elif (s[i] == "x" and l1[i] == "W") or (s[i] == "o" and l1[i] == "S") and l[0] != l1[i-1]: l1 = "-1" for i in range(n-2): l2.append("S") for i in range(n): if i+1 <= n-1 and i != 0: if (s[i] == "x" and l2[i] == "S") or (s[i] == "o" and l2[i] == "W"): if l2[i-1] == "S": l2[i+1] = "W" else: l2[i+1] = "S" else: l2[i+1] = l2[i] elif i == 0: pass else: if(s[i] == "x" and l2[i] == "S") or (s[i] == "o" and l2[i] == "W") and l2[0] == l2[i-1]: l2 = "-1" elif (s[i] == "x" and l2[i] == "W") or (s[i] == "o" and l2[i] == "S") and l2[0] != l2[i-1]: l2 = "-1" if t1 != "-1": for i in t1: print(i,end="") elif t2 != "-1": for i in t2: print(i,end="") elif l1 != "-1": for i in l1: print(i,end="") elif l2 != "-1": for i in l2: print(i,end="") else:print("-1")
s915140558
p03798
u806201407
1493868577
Python
Python (3.4.3)
py
Runtime Error
205
6260
826
def check(s, ans, i) : return s[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, -2 ) == 0 and check(s, ans, -1) == 0 : ans += [1] # print(ans) return ans N = int(input()) s = input() data = [0] * N for i in range(N) : data[i] = 1 if s[i] == 'o' 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('S' if ans[i] == 1 else 'W', end = "") print()
s039586610
p03798
u132360211
1490028335
Python
Python (3.4.3)
py
Runtime Error
17
2940
751
io = STDIN $n=io.gets.chomp.to_i $s=io.gets.chomp $ans=' '*$n def check2(i) return true if $ans[i]==' ' nxt = i==$n-1 ? 0 : i+1 return true if $ans[i-1]==' ' || $ans[nxt]==' ' rslt=case $s[i] when "o" if $ans[i]=="S" $ans[i-1]==$ans[nxt] else $ans[i-1]!=$ans[nxt] end else if $ans[i]=="S" $ans[i-1]!=$ans[nxt] else $ans[i-1]==$ans[nxt] end end # p ["check2",i,rslt,$s[i],$ans[i-1],$ans[i],$ans[nxt]] rslt end def check1(i) if i==$n if check2(i-1) return $ans else return false end else ["S","W"].each do |a| $ans[i]=a if check2(i-1) return true if check1(i+1) end end return false end end puts check1(0) ? $ans : -1
s398898237
p03798
u117629640
1488559429
Python
Python (3.4.3)
py
Runtime Error
49
6184
457
# coding: utf-8 def main(): n = int(input()) data = list(input()) result = [] for i in range(n): if len(result) == i-1: if data[i] == 'o' and data[i+1] == 'o': result.append('W') result.append('W') else: result.append('S') if len(result) < 3 or 'W' not in result: print(-1) else: print(result) if __name__ == '__main__': main()
s190615540
p03798
u762603420
1487898231
Python
Python (3.4.3)
py
Runtime Error
112
6636
2620
# -*- coding: utf-8 -*- def check(s, ans): if len(s) != len(ans): return False; for i in range(0, len(s)): pre = i - 1 next = i + 1 if i == 0: pre = len(s) - 1 if i == len(s) - 1: next = 0 if ans[i] == "S": if s[i] == "o": if ans[pre] != ans[next]: return False else: if ans[pre] == ans[next]: return False else: if s[i] == "x": if ans[pre] != ans[next]: return False else: if ans[pre] == ans[next]: return False return True def getAns(s, ans, idx, n): if idx == n - 1: if check(a, ans): return ans else: return [] if idx == 0: if ans[idx] == "S": if s[idx] == "o": ans[n - 1] = ans[1] else: if ans[1] == "S": ans[n - 1] = "W" else: ans[n - 1] = "S" else: if s[idx] == "x": ans[n - 1] = ans[1] else: if ans[1] == "S": ans[n - 1] = "W" else: ans[n - 1] = "S" return getAns(s, ans, idx + 1, n) pre = idx - 1 next = idx + 1 # 羊 if ans[idx] == "S": if s[idx] == "o": ans[next] = ans[pre] else: if ans[pre] == "S": ans[next] = "W" else: ans[next] = "S" # 狼 else: if s[idx] == "x": ans[next] = ans[pre] else: if ans[pre] == "S": ans[next] = "W" else: ans[next] = "S" return getAns(s, ans, idx + 1, n) def arrayToString(arry): s = "" for i in range(0, len(arry)): s+= arry[i] return s n = int(input()) a = input() s = [a[i] for i in range(0, len(a))] ans = ["S" for i in range(0, len(a))] ans1 = ans[:] ans1 = getAns(s, ans1, 0, n) if len(ans1) != 0: print(arrayToString(ans1)) quit() ans2 = ans[:] ans2[0] = "W" ans2 = getAns(s, ans2, 0, n) if len(ans2) != 0: print(arrayToString(ans2)) quit() ans3 = ans[:] ans3[1] = "W" ans3 = getAns(s, ans3, 0, n) if len(ans3) != 0: print(arrayToString(ans3)) quit() ans4 = ans[:] ans4[0] = "W" ans4[1] = "W" ans4 = getAns(s, ans4, 0, n) if len(ans4) != 0: print(arrayToString(ans4)) quit() print("-1")
s964438322
p03798
u762603420
1487897741
Python
Python (3.4.3)
py
Runtime Error
116
6564
2569
# -*- coding: utf-8 -*- def check(s, ans): for i in range(0, len(s)): pre = i - 1 next = i + 1 if i == 0: pre = len(s) - 1 if i == len(s) - 1: next = 0 if ans[i] == "S": if s[i] == "o": if ans[pre] != ans[next]: return False else: if ans[pre] == ans[next]: return False else: if s[i] == "x": if ans[pre] != ans[next]: return False else: if ans[pre] == ans[next]: return False return True def getAns(s, ans, idx, n): if idx == n - 1: if check(a, ans): return ans else: return [] if idx == 0: if ans[idx] == "S": if s[idx] == "o": ans[n - 1] = ans[1] else: if ans[1] == "S": ans[n - 1] = "W" else: ans[n - 1] = "S" else: if s[idx] == "x": ans[n - 1] = ans[1] else: if ans[1] == "S": ans[n - 1] = "W" else: ans[n - 1] = "S" return getAns(s, ans, idx + 1, n) pre = idx - 1 next = idx + 1 # 羊 if ans[idx] == "S": if s[idx] == "o": ans[next] = ans[pre] else: if ans[pre] == "S": ans[next] = "W" else: ans[next] = "S" # 狼 else: if s[idx] == "x": ans[next] = ans[pre] else: if ans[pre] == "S": ans[next] = "W" else: ans[next] = "S" return getAns(s, ans, idx + 1, n) def arrayToString(arry): s = "" for i in range(0, len(arry)): s+= arry[i] return s n = int(input()) a = input() s = [a[i] for i in range(0, len(a))] ans = ["S" for i in range(0, len(a))] ans1 = ans[:] ans1 = getAns(s, ans1, 0, n) if len(ans1) != 0: print(arrayToString(ans1)) quit() ans2 = ans[:] ans2[0] = "W" ans2 = getAns(s, ans2, 0, n) if len(ans2) != 0: print(arrayToString(ans2)) quit() ans3 = ans[:] ans3[1] = "W" ans3 = getAns(s, ans3, 0, n) if len(ans3) != 0: print(arrayToString(ans3)) quit() ans4 = ans[:] ans4[0] = "W" ans4[1] = "W" ans4 = getAns(s, ans4, 0, n) if len(ans4) != 0: print(arrayToString(ans4)) quit() print("-1")
s384449652
p03798
u898690911
1487771257
Python
Python (3.4.3)
py
Runtime Error
216
6384
2713
import sys def point(main_animal,main_animal_answer,previous_animal): next_animal='' if main_animal=='S': if main_animal_answer=='o': next_animal=previous_animal else: if previous_animal=='W': next_animal='S' else: next_animal='W' else: if main_animal_answer=='x': next_animal=previous_animal else: if previous_animal=='W': next_animal='S' else: next_animal='W' return next_animal def cheacker(main_animal,main_animal_answer,previous_animal,next_animal): if (main_animal=="S" and main_animal_answer=="o")or(main_animal=='W' and main_animal_answer=='x' ): if(previous_animal==next_animal): return True else: return False elif (main_animal=="S"and main_animal_answer=="x")or(main_animal=="W" and main_animal_answer=="o"): if(previous_animal!=next_animal): return True else: return False else: return False def cheack_list(animal_list,answer_list): final_ans=True for i in range(1,len(animal_list)-2): if i==1: ans=cheacker(animal_list[i],answer_list[i],animal_list[len(animal_list)-1],animal_list[i+1]) else: ans=cheacker(animal_list[i],answer_list[i],animal_list[i-1],animal_list[i+1]) if ans==False: final_ans=False else: pass return final_ans N=input() str=input() answer_list=[] animal_list=[] for i in str: answer_list.append(i) animal_list.append("S") animal_list.append("S") for i in range(1,len(answer_list)-1): animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1])) ans=cheack_list(animal_list,answer_list) if ans: print(animal_list) sys.exit animal_list.clear animal_list.append("S") animal_list.append("W") for i in range(1,len(answer_list)-1): animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1])) ans=cheack_list(animal_list,answer_list) if ans: print(animal_list) sys.exit animal_list.clear animal_list.append("W") animal_list.append("S") for i in range(1,len(answer_list)-1): animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1])) ans=cheack_list(animal_list,answer_list) if ans: print(animal_list) sys.exit animal_list.clear animal_list.append("W") animal_list.append("W") for i in range(1,len(answer_list)-1): animal_list.append(point(animal_list[i],answer_list[i],animal_list[i-1])) ans=cheack_list(animal_list,answer_list) if ans: print(animal_list) sys.exit print("-1")
s819974756
p03798
u581309643
1487476389
Python
Python (3.4.3)
py
Runtime Error
209
134260
582
N = int(input()) s = input() r = {'S' : 'W', 'W': 'S'} a = 'SS' ans = -1 for a in ('SS', 'SW', 'WS', 'WW'): for i in range(1,N): print(a) if s[i] == 'o': if a[i] == 'S': a += a[i-1] else: a += r[a[i-1]] else: if a[i] == 'S': a += r[a[i-1]] else: a += a[i-1] if a[N] == a[0]: if (s[0] == 'o') and (a[N-1] == a[1]): ans = a[:-1] elif (s[0] == 'x') and (a[N-1] == r[a[1]]): ans = a[:-1] print(ans)
s822130698
p03798
u314057689
1487476040
Python
Python (3.4.3)
py
Runtime Error
19
3064
816
from test import set_stdin_sandbox set_stdin_sandbox() import itertools N = int(input()) s = list(map(lambda x: True if x == "o" else False, list(input()))) f = lambda x,y: not(x^y) def hantei(N,s): for onetwo in itertools.product((True, False), (True, False)): res = {} for n in range(N): if n == 0: res[n] = onetwo[0] elif n == 1: res[n] = onetwo[1] else: res[n] = f(res[n-2], f(res[n-1], s[n-1])) # check s[0] if not ((res[1] == res[N-1]) ^ res[0]) == s[0]: if not ((res[0] == res[N-2]) ^ res[N-1]) == s[N-1]: print(''.join(map(lambda x: "S" if x == True else "W", res.values()))) return True return False if not hantei(N, s): print(-1)
s257955649
p03798
u314057689
1487475307
Python
Python (3.4.3)
py
Runtime Error
30
4900
834
import itertools N = int(input()) s = list(map(lambda x: True if x == "o" else False, list(input()))) # N = 6 # s = "ooxoox" # N = 3 # s = "oox" s = [True, True, False] def hantei(N,s): f = lambda x,y: not(x^y) for onetwo in itertools.product((True, False), (True, False)): res = {} for n in range(N): if n == 0: res[n] = onetwo[0] elif n == 1: res[n] = onetwo[1] else: res[n] = f(res[n-2], f(res[n-1], s[n-1])) # check s[0] if not ((res[1] == res[N-1]) ^ res[0]) == s[0]: if not ((res[0] == res[N-2]) ^ res[N-1]) == s[N-1]: print(''.join(map(lambda x: "S" if x == 0 else "W", res.values()))) return True return False if not hantei(N, s): print(-1)
s235747546
p03798
u583826716
1487474342
Python
Python (3.4.3)
py
Runtime Error
92
6408
1447
SHEEP = True WOLF = False def print_tree(tree): print(''.join(['S' if e else 'W' for e in tree])) def calc_next_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos - 1] else: return not tree[cur_pos - 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos - 1] else: return tree[cur_pos - 1] def calc_prev_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos + 1] else: return not tree[cur_pos + 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos + 1] else: return tree[cur_pos + 1] def wfs(tree, cur_pos, N): tree[cur_pos + 1] = calc_next_animal(tree, cur_pos) cur_pos += 1 if cur_pos == N - 1: return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0) else: return wfs(tree, cur_pos, N) if __name__ == '__main__': N = int(input()) answer = [True if i == 'o' else False for i in input().rstrip()] aa = [[WOLF, WOLF] , [WOLF, SHEEP] , [SHEEP, SHEEP] , [SHEEP, WOLF]] super_list = [0] * int(2E5) for a in aa: super_list[:2] = a if wfs(super_list, 1, N): print_tree(super_list[:N]) break else: print(-1)
s797378759
p03798
u583826716
1487474285
Python
Python (3.4.3)
py
Runtime Error
92
6416
1455
SHEEP = True WOLF = False def print_tree(tree): print(''.join(['S' if e else 'W' for e in tree])) def calc_next_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos - 1] else: return not tree[cur_pos - 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos - 1] else: return tree[cur_pos - 1] def calc_prev_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos + 1] else: return not tree[cur_pos + 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos + 1] else: return tree[cur_pos + 1] def wfs(tree, cur_pos, N) -> bool: tree[cur_pos + 1] = calc_next_animal(tree, cur_pos) cur_pos += 1 if cur_pos == N - 1: return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0) else: return wfs(tree, cur_pos, N) if __name__ == '__main__': N = int(input()) answer = [True if i == 'o' else False for i in input().rstrip()] aa = [[WOLF, WOLF] , [WOLF, SHEEP] , [SHEEP, SHEEP] , [SHEEP, WOLF]] super_list = [0] * int(2E5) for a in aa: super_list[:2] = a if wfs(super_list, 1, N): print_tree(super_list[:N]) break else: print(-1)
s558187105
p03798
u583826716
1487474230
Python
Python (3.4.3)
py
Runtime Error
88
5632
1455
SHEEP = True WOLF = False def print_tree(tree): print(''.join(['S' if e else 'W' for e in tree])) def calc_next_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos - 1] else: return not tree[cur_pos - 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos - 1] else: return tree[cur_pos - 1] def calc_prev_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos + 1] else: return not tree[cur_pos + 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos + 1] else: return tree[cur_pos + 1] def wfs(tree, cur_pos, N) -> bool: tree[cur_pos + 1] = calc_next_animal(tree, cur_pos) cur_pos += 1 if cur_pos == N - 1: return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0) else: return wfs(tree, cur_pos, N) if __name__ == '__main__': N = int(input()) answer = [True if i == 'o' else False for i in input().rstrip()] aa = [[WOLF, WOLF] , [WOLF, SHEEP] , [SHEEP, SHEEP] , [SHEEP, WOLF]] super_list = [0] * int(1E5) for a in aa: super_list[:2] = a if wfs(super_list, 1, N): print_tree(super_list[:N]) break else: print(-1)
s153461949
p03798
u314057689
1487473809
Python
Python (3.4.3)
py
Runtime Error
18
3192
1642
import itertools N = int(input(l)) s = list(input()) # N = 6 # s = "ooxoox" N = 3 s = "oox" def hantei(N,s): for onetwo in itertools.product((0, 1), (0, 1)): res = {} for n in range(N): if n == 0: res[n] = onetwo[0] elif n == 1: res[n] = onetwo[1] else: if res[n-1] == 0 and s[n-1] == "o": res[n] = res[n-2] elif res[n-1] == 0 and s[n-1] == "x": res[n] = 1 if res[n-2] == 0 else 0 elif res[n-1] == 1 and s[n-1] == "o": res[n] = 1 if res[n-2] == 0 else 0 elif res[n-1] == 1 and s[n-1] == "x": res[n] = res[n-2] # check s[0] if (res[1] == res[N-1]) and res[0] == 0 and s[0] == "x": continue if (res[1] == res[N-1]) and res[0] == 1 and s[0] == "o": continue if (res[1] != res[N-1]) and res[0] == 0 and s[0] == "o": continue if (res[1] != res[N-1]) and res[0] == 1 and s[0] == "x": continue # check s[n-1] if (res[0] == res[N-2]) and res[N-1] == 0 and s[N-1] == "x": continue if (res[0] == res[N-2]) and res[N-1] == 1 and s[N-1] == "o": continue if (res[0] != res[N-2]) and res[N-1] == 0 and s[N-1] == "o": continue if (res[0] != res[N-2]) and res[N-1] == 1 and s[N-1] == "x": continue print(''.join(map(lambda x: "S" if x == 0 else "W", res.values()))) return True return False if not hantei(N, s): print(-1)
s485420600
p03798
u277343138
1487473523
Python
Python (3.4.3)
py
Runtime Error
78
4632
672
n = int(input()) s = input() flag = False def rec(t, i, s, n): global flag if flag: return l = len(t) if 2 < l: if t[i%l] == 'S' and (t[(i-1)%l] == t[(i+1)%l] and s[i%l] == 'x' or t[(i-1)%l] != t[(i+1)%l] and s[i%l] == 'o'): return elif t[i%l] == 'W' and (t[(i-1)%l] == t[(i+1)%l] and s[i%l] == 'o' or t[(i-1)%l] != t[(i+1)%l] and s[i%l] == 'x'): return if i == n + 1: print(t) flag = True return if l < n: rec(t + 'S', i+1, s, n) rec(t + 'W', i+1, s, n) else: rec(t, i+1, s, n) rec('', -2, s, n) if not flag: print('-1')
s869840713
p03798
u583826716
1487473451
Python
Python (3.4.3)
py
Runtime Error
86
4944
1354
SHEEP = True WOLF = False def print_tree(tree): print(''.join(['S' if e else 'W' for e in tree])) def calc_next_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos - 1] else: return not tree[cur_pos - 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos - 1] else: return tree[cur_pos - 1] def calc_prev_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos + 1] else: return not tree[cur_pos + 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos + 1] else: return tree[cur_pos + 1] def wfs(tree, cur_pos, N) -> bool: tree.append(calc_next_animal(tree, cur_pos)) cur_pos += 1 if cur_pos == N - 1: return tree[0] == calc_next_animal(tree, cur_pos) and tree[-1] == calc_prev_animal(tree, 0) else: return wfs(tree, cur_pos, N) N = int(input()) answer = [True if i == 'o' else False for i in input().rstrip()] a = [WOLF, WOLF] b = [WOLF, SHEEP] c = [SHEEP, SHEEP] d = [SHEEP, WOLF] if wfs(a, 1, N): print_tree(a) elif wfs(b, 1, N): print_tree(b) elif wfs(c, 1, N): print_tree(c) elif wfs(d, 1, N): print_tree(d) else: print(-1)
s650263593
p03798
u583826716
1487473425
Python
Python (3.4.3)
py
Runtime Error
89
4852
1354
SHEEP = True WOLF = False def print_tree(tree): print(''.join(['S' if e else 'W' for e in tree])) def calc_next_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos - 1] else: return not tree[cur_pos - 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos - 1] else: return tree[cur_pos - 1] def calc_prev_animal(tree, cur_pos): if answer[cur_pos]: if tree[cur_pos] == SHEEP: return tree[cur_pos + 1] else: return not tree[cur_pos + 1] else: if tree[cur_pos] == SHEEP: return not tree[cur_pos + 1] else: return tree[cur_pos + 1] def wfs(tree, cur_pos, N) -> bool: tree.append(calc_next_animal(tree, cur_pos)) cur_pos += 1 if cur_pos == N - 1: return tree[0] == calc_next_animal(tree, cur_pos) and tree[-1] == calc_prev_animal(tree, 0) else: return wfs(tree, cur_pos, N) N = int(input()) answer = [True if i == 'o' else False for i in input().rstrip()] a = [WOLF, WOLF] b = [WOLF, SHEEP] c = [SHEEP, SHEEP] d = [SHEEP, WOLF] if wfs(a, 1, N): print_tree(a) elif wfs(b, 1, N): print_tree(b) elif wfs(c, 1, N): print_tree(c) elif wfs(d, 1, N): print_tree(d) else: print(-1)
s126151127
p03799
u143051858
1594052584
Python
Python (3.8.2)
py
Runtime Error
26
8992
162
s,c = map(int,input().split()) if s*2 <= c: res = s c -= s*2 s = 0 else: res += c//2 c = 0 #print(res,s,c) if c: res += c//4 print(res)
s971180134
p03799
u143051858
1594052551
Python
Python (3.8.2)
py
Runtime Error
27
9152
162
s,c = map(int,input().split()) if s*2 <= c: res = s c -= s*2 s = 0 else: res += c//2 m = 0 #print(res,s,c) if c: res += c//4 print(res)
s909983794
p03799
u143051858
1594052163
Python
Python (3.8.2)
py
Runtime Error
25
9136
157
s,c = map(int,input().split()) res = 0 if s*2 <= c: res += s c -= s*2 res+= c else: res += c//2 c //= 2 if c: res += m//4 print(res)
s015264516
p03799
u179169725
1593352984
Python
Python (3.8.2)
py
Runtime Error
23
9096
67
N,M=map(int,input().split()) n1=min(N,M//2) print(ans+(M-2*n1)//4)
s779741326
p03799
u179169725
1593352891
Python
Python (3.8.2)
py
Runtime Error
20
9120
81
N,M=map(int,input().split()) n1=min(N,M//2) N-=n1 M-=2*n1 print(ans+(M-2*n1)//4)
s837428495
p03799
u179169725
1593352828
Python
Python (3.8.2)
py
Runtime Error
26
9092
134
N,M=map(int,input().split()) n1=min(N,M//2) N-=n1 M-=2*n1 if N==0: ans=n1+M//4 else: ans=n1+N//2 raise ValueError() print(ans)
s477863973
p03799
u514118270
1592961508
Python
Python (3.8.2)
py
Runtime Error
29
10024
2224
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10**9) mod = 10**9+7 N = i() S = s() a = 'S' b = 'W' kouho = [[a,a],[a,b],[b,a],[b,b]] for a,b in kouho: S1 = [a,b] for i in range(1,N): if S[i] == 'o': if S1[i] == 'S': if S1[i-1] == 'S': S1.append('S') else: S1.append('W') else: if S1[i-1] == 'S': S1.append('W') else: S1.append('S') else: if S1[i] == 'S': if S1[i-1] == 'S': S1.append('W') else: S1.append('S') else: if S1[i-1] == 'S': S1.append('S') else: S1.append('W') if S1[-1] != a: continue S1 = S1[:N] if a == 'S' and b == 'S': if S[0] == 'o': if S1[-1] == 'S': print(''.join(S1)) exit() else: if S1[-1] == 'W': print(''.join(S1)) exit() elif a == 'S' and b == 'W': if S[0] == 'o': if S1[-1] == 'W': print(''.join(S1)) exit() else: if S1[-1] == 'S': print(''.join(S1)) exit() elif a == 'W' and b == 'S': if S[0] == 'o': if S1[-1] == 'W': print(''.join(S1)) exit() else: if S1[-1] == 'S': print(''.join(S1)) exit() else: if S[0] == 'o': if S1[-1] == 'S': print(''.join(S1)) exit() else: if S1[-1] == 'W': print(''.join(S1)) exit() print(-1)
s002775365
p03799
u593567568
1591217797
Python
Python (3.4.3)
py
Runtime Error
17
2940
166
N,M = map(int,inpu().split()) def solve(N,M): # 今あるもの if M < N * 2: return N M -= N * 2 ans = N + M // 3 return ans print(solve(N,M))
s112085728
p03799
u810356688
1590933414
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38384
519
import sys def input(): return sys.stdin.readline().rstrip() def main(): n=int(input()) s=input() for ans in ("SS","SW","WS","WW"): for c in s[1:]: if ans[-1]=="S": ans+="W" if (ans[-2]=="W")^(c=="x") else "S" else: ans+="S" if (ans[-2]=="W")^(c=="x") else "W" if ans[0]==ans[-1] and (((ans[0]=="W")^(s[0]=="x"))^(ans[-2]==ans[1])): print(ans[:-1]) sys.exit() print(-1) if __name__=='__main__': main()
s033869511
p03799
u535171899
1588904884
Python
Python (3.4.3)
py
Runtime Error
2128
1407348
432
import sys N, M = map(int, input().split()) S = [0] * M C = [0] * M for i in range(M): S[i], C[i] = map(int, input().split()) for i in range(1000): string = str(i) if len(string) != N: continue flag = True for j in range(M): if string[S[j] - 1] == str(C[j]): None else: flag = False break if flag: print(i) sys.exit(0) print("-1")
s861398287
p03799
u995062424
1586016834
Python
Python (3.4.3)
py
Runtime Error
17
2940
101
N, M = map(int, input().split()) if(2*N <= M): m = M-2*N print(N+m//4) else: print(m//2)
s083943727
p03799
u994521204
1583828297
Python
Python (3.4.3)
py
Runtime Error
17
2940
106
n,m=map(int, input().split()) p1=n p2=m//2 if p1>p2: print(p2) else: delta=p2-p1 print(delta//2+p1)
s383436807
p03799
u994521204
1583828231
Python
Python (3.4.3)
py
Runtime Error
18
2940
105
n,m=map(int,input().split()) p1=n p2=m//2 if p1>p2: print(p2) else: delta=p2-p1 print(delta//2+p1)
s418282455
p03799
u994521204
1583828191
Python
Python (3.4.3)
py
Runtime Error
17
2940
106
n,m=map(int,input().split()) p1=n p2=m//2 if p1>p2: print(p2) else: delta=p2-p1 print(delta//2+p1)
s289803883
p03799
u984276646
1580338129
Python
Python (3.4.3)
py
Runtime Error
17
3060
166
N, M = map(int, input().split()) if 2 * N > M: print(M // 2) else: C = M // 2 n = (C - N) // 2 print(max(min(S+n-1, C-n+1), min(S+n, C-n), min(S+n+1, C-n-1)))
s083561281
p03799
u495415554
1576986750
Python
PyPy3 (2.4.0)
py
Runtime Error
164
38256
98
N, M = map(int, input().split()) if N >= 2 * M: print(M // 2) else: print(N + ((M - 2 * N) // 4))
s445746416
p03799
u495415554
1576986720
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38384
105
N, M = map(int, input().split()) if N >= 2 * M: print(M // 2) else: print(N + ((M - 2 * N) // 4)
s257149266
p03799
u936985471
1574024136
Python
Python (3.4.3)
py
Runtime Error
17
2940
76
n,m=map(int,input().split()) c=m//2 if n>c: print(c) else: print(s+c//2)
s812252560
p03799
u503111914
1569716359
Python
Python (3.4.3)
py
Runtime Error
17
2940
86
N,M = map(int()input().split()) if N <= M//2+1: print(N) else: print(N+(M-N*2)//4)
s770115038
p03799
u850491413
1569183673
Python
PyPy3 (2.4.0)
py
Runtime Error
303
65644
1243
import sys from collections import deque, defaultdict import copy import bisect sys.setrecursionlimit(10 ** 9) import math import heapq from itertools import product, permutations,combinations import fractions import sys def input(): return sys.stdin.readline().strip() N = int(input()) a = list(map(int, input().split())) top_list = [0] for i in range(1, N): if a[i] > a[top_list[-1]]: top_list.append(i) num_list = [0]*N com = [] for i in range(len(top_list)): bisect.insort(com, a[top_list[i]]) for i in range(N - 1, top_list[-1], -1): bisect.insort(com, a[i]) stock = 0 #print(com, top_list, num_list) for top in range(len(top_list) - 2, -1, -1): for i in range(top_list[top + 1] - 1, top_list[top], -1): #bisect.insort(com, a[i]) com.append(a[i]) com.sort() judge = 0 total = stock*(a[top_list[top + 1]] - a[top_list[top]]) #print(total, (a[top_list[top + 1]] - a[top_list[top]])*stock, top) while judge == 0: x = com.pop() if x > a[top_list[top]]: total += x - a[top_list[top]] stock += 1 else: bisect.insort(com, x) judge = 1 num_list[top_list[top + 1]] = total #print(com, top_list, num_list, stock) num_list[top_list[0]] = sum(a) - sum(num_list) for i in range(N): print(num_list[i])
s610770009
p03799
u637824361
1565237114
Python
Python (3.4.3)
py
Runtime Error
17
2940
104
N, M = map(int, input().split()) ans = 0 if N > M//2: print(M//2) else: p = M - 2*N print(N + p//4
s654128883
p03799
u426108351
1559234840
Python
Python (3.4.3)
py
Runtime Error
17
3064
354
N = int(input()) a = list(map(int, input().split())) b = [] for i in range(N): b.append([a[i], i+1]) b.sort(reverse = True) ans = [0]*(N+1) mini = N+1 for i in range(N-1): mini = min(mini, b[i][1]) if b[i+1][0] - b[i][0] < 0: ans[mini] += (b[i][0] - b[i+1][0])*(i+1) ans[1] += N*min(b[-1][0]) for i in range(N): print(ans[i+1])
s189944502
p03799
u426108351
1559234819
Python
Python (3.4.3)
py
Runtime Error
17
3064
354
N = int(input()) a = list(map(int, input().split())) b = [] for i in range(N): b.append([a[i], i+1]) b.sort(reverse = True) ans = [0]*(N+1) mini = N+1 for i in range(N-1): mini = min(mini, b[i][1]) if b[i+1][0] - b[i][0] < 0: ans[mini] += (b[i][0] - b[i+1][0])*(i+1) ans[1] += N*min(b[-1][0]) for i in range(N): print(ans[i+1])
s590546724
p03799
u724742135
1556402104
Python
Python (3.4.3)
py
Runtime Error
17
2940
148
from sys import exit, stdin N, M = [int(_) for _ in stdin.readline().rstrip().split()] r = M-2*N if r <= 0: print(N//2) else: pritnt(N+r//4)
s349522232
p03799
u271469978
1555939322
Python
Python (3.4.3)
py
Runtime Error
17
2940
97
n, m = map(int, input().split()) c = m - 2*n if c <= 0: pirnt(m//2) else: print(n + c//4)
s148334189
p03799
u271469978
1555939101
Python
Python (3.4.3)
py
Runtime Error
19
2940
94
n, m = map(int, input().split()) c = m - 2*n if c <= 0: pirnt(n) else: print(n + c//4)
s828378128
p03799
u692782635
1531642638
Python
Python (3.4.3)
py
Runtime Error
17
2940
536
from functools import cmp_to_key n = int(input()) a = list(map(int, input().split())) def group(a): d = {} for i, x in enumerate(a): d.setdefault(x, []).append(i) s = sorted(d.items(), key=cmp_to_key(lambda x, y: x[0] - y[0]), reverse=True) return list(map(lambda x: [x[0], x[1][0], len(x[1])], s)) ans = [0] * n g = group(a) g.append([0, 0, 0]) for c, n in zip(g[:-1], g[1:]): ans[c[1]] += (c[0] - n[0]) * c[2] n[1] = min(c[1], n[1]) n[2] += c[2] [print(a) for a in ans]
s591442952
p03799
u711574130
1488565497
Python
Python (2.7.6)
py
Runtime Error
11
2692
421
# -*- coding:utf-8 -*- from operator import itemgetter n = int(raw_input()) a = [[int(k),i+1] for i,k in enumerate(raw_input().split())] a.sort(key=itemgetter(0),reverse=True) s = [] b = [] a.append([0,0]) for i,p in enumerate(a[:-1]): if not p[0] == a[i+1][0]: q = a[i][0] - a[i+1][0] y = [z[1] for z in a[:i+1]] s.extend([min(y)]*(i+1)*q) for i in xrange(1,int(n)+1): print(s.count(i))
s535884120
p03799
u848877025
1488475627
Python
Python (2.7.6)
py
Runtime Error
3496
23428
331
def main(): s, c = map(int, raw_input().split()) count = 0 for i in range(s): if(c >= 2): count += 1 c -= 2 else: break for i in range(c): if(c >= 4): count += 1 c -= 4 else: break return count print main()
s392532575
p03799
u848877025
1488475426
Python
Python (2.7.6)
py
Runtime Error
10
2568
331
def main(): s, c = map(int, input.row().split()) count = 0 for i in range(s): if(c >= 2): count += 1 c -= 2 else: break for i in range(c): if(c >= 4): count += 1 c -= 4 else: break return count print main()
s770478167
p03799
u663230781
1488384874
Python
Python (2.7.6)
py
Runtime Error
12
2696
194
n, m = map(int, raw_input().rstrip("\n").split(" ")) answer = 0 if (n * 2) >= m: answer = m / 2 else: answer = n + ( m - (n *2) ) / 3) print answer print calc_scc(12345,678901), 175897
s625728963
p03799
u886545507
1487692593
Python
Python (2.7.6)
py
Runtime Error
10
2568
95
#ARC069A n,m=map(int,raw_input().split()) if n>m*2: res=c/2 else: res=n+(m-2*n)/4 print res
s621566889
p03799
u886545507
1487691913
Python
Python (2.7.6)
py
Runtime Error
10
2568
93
#ARC069A n,m=map(int,raw_input().split()) if n>m*2: res=c/2 else: res=(n*2+m)/4 print res
s708906623
p03799
u749912909
1487571463
Python
Python (2.7.6)
py
Runtime Error
11
2568
208
# -*- coding: utf-8 -*- N, M = map(int, raw_input().split()) if M == 2*N: print("%d"%M) elif M < 2*M: print("%d"%M + (N - 2*M - (N - 2*M)%4) / 4) else: print("%d"%N + (M - 2*N - (M - 2*N) %4) / 4)
s241421586
p03799
u749912909
1487571348
Python
Python (3.4.3)
py
Runtime Error
17
2940
186
N, M = map(int, raw_input().split()) if M == 2*N: print("%d"%M) elif M < 2*M: print("%d"%M + (N - 2*M - (N - 2*M)%4) / 4) else: print("%d"%N + (M - 2*N - (M - 2*N) %4) / 4)
s849995107
p03799
u749912909
1487571228
Python
Python (3.4.3)
py
Runtime Error
17
3060
234
def solve(M, N): if M == 2*N: return M elif M < 2*M: return M + (N - 2*M - (N - 2*M)%4) / 4 else: return N + (M - 2*N - (M - 2*N) %4) / 4 M, N = map(int, raw_input().split()) print("%d"%solve(M, N))
s845370791
p03799
u749912909
1487570951
Python
Python (3.4.3)
py
Runtime Error
17
3060
210
def solve(M, N): if M == 2*N: return M elif M < 2*M: return M + int((N - 2*M) / 4) else: return N + int((M - 2*N) / 4) M, N = map(int, raw_input().split()) print(solve(M, N))
s820827028
p03799
u749912909
1487570721
Python
Python (3.4.3)
py
Runtime Error
17
3064
196
M, N = raw_input().split(" ") def solve(M, N): if M == 2*N: return M elif M < 2*M: return M + int((N - 2*M) / 4) else: return N + int((M - 2*N) / 4) solve(M, N)
s108955010
p03799
u749912909
1487570489
Python
Python (3.4.3)
py
Runtime Error
17
3060
222
import math def solve(M, N): if M == 2*N: return M elif M < 2*M: return M + math.floor((N - 2*M) / 4) else: return N + math.floor((M - 2*N) / 4) M, N = raw_input().split(" ") solve(M, N)
s326157049
p03799
u622011073
1487488261
Python
Python (3.4.3)
py
Runtime Error
18
3064
250
n=int(input());s=input();a=['SS','WS','SW','WW'] for i in range(n): for j in range(4):a[j]+='SW'[::-1 if s[i]=='o' else 1][a[j][i]==a[j][i+1]] for i in range(4): if a[i][1]==a[i][n+1] and a[i][0] == a[i][n]:print(a[i][1:n+1]);exit() print(-1)
s598303928
p03799
u369752439
1487483209
Python
Python (2.7.6)
py
Runtime Error
11
2824
2192
def findNextAnimal(oxList, swList, index): nextAns = oxList[index] before = swList[index-1] animal = swList[index] nextAnimal = "" if(nextAns == "o" and before == "S" and animal == "S"): nextAnimal = "S" elif(nextAns == "o" and before == "S" and animal == "W"): nextAnimal = "W" elif(nextAns == "o" and before == "W" and animal == "S"): nextAnimal = "W" elif(nextAns == "o" and before == "W" and animal == "W"): nextAnimal = "S" elif(nextAns == "x" and before == "S" and animal == "S"): nextAnimal = "W" elif(nextAns == "x" and before == "S" and animal == "W"): nextAnimal = "S" elif(nextAns == "x" and before == "W" and animal == "S"): nextAnimal = "S" elif(nextAns == "x" and before == "W" and animal == "W"): nextAnimal = "W" return nextAnimal def checkList(oxList, swList): ans = 0 if(swList[-1] == "S"): if(oxList[-1] == "x" and swList[-2] != swList[0]): ans = 1 elif(oxList[-1] == "o" and swList[-2] == swList[0]): ans = 1 elif(swList[-1] == "W"): if(oxList[-1] == "x" and swList[-2] == swList[0]): ans = 1 elif(oxList[-1] == "o" and swList[-2] != swList[0]): ans = 1 ans2 = 0 if(swList[0] == "S"): if(oxList[0] == "x" and swList[1] != swList[-1]): ans2 = 1 elif(oxList[0] == "o" and swList[1] == swList[-1]): ans2 = 1 elif(swList[0] == "W"): if(oxList[0] == "x" and swList[1] == swList[-1]): ans2 = 1 elif(oxList[0] == "o" and swList[1] != swList[-1]): ans2 = 1 return ans*ans2 n = raw_input().strip().upper() oxList = raw_input().strip().lower() ans = -1 for s0 in ["S", "W"]: for s1 in ["S","W"]: swList = [0]*int(n) swList[0] = s0 swList[1] = s1 for i in range(2, int(n)): nextAnimal = findNextAnimal(oxList, swList, i-1) swList[i] = nextAnimal flag = checkList(oxList, swList) if(flag == 1): ans = "" for s in swList: ans += s print ans
s687644152
p03799
u880644800
1487475214
Python
Python (3.4.3)
py
Runtime Error
18
3064
798
def solve(s, c): """rv = min(Sr, Cr//2), where Sr = S + a Cr = C - 2a # a>=0, a is number of (2c->S) conversions thus rv = max(min(S + a, C//2 - a) for a in range(0, C//2)) if a >=0, optimum is Sr == Cr//2, thus S + a == Cr//2 - a a = (C//2 - S) / 2 """ a = (c / 2 - s) / 2 if a < 0: a = 0 al = int(a) ar = int(a) + 1 return max(min(s + a, c//2 - a) for a in (al, ar)) if __name__ == "__main__": import sys S, C = sys.stdin.readline().split() print(solve(s, c)) def test_solve(): assert solve(1, 2) == 1 assert solve(0, 4) == 1 assert solve(0, 1) == 0 def test_atcode(): assert solve(1, 6) == 2 assert solve(12345, 678901) == 175897
s282792722
p03799
u866746776
1487470308
Python
Python (3.4.3)
py
Runtime Error
17
2940
182
n, m = input().split() num_s = int(n) num_c = int(m) if num_c <= num_s * 2: print(num_c // c) else: scc = num_s num_s = 0 num_c -= 2 * scc scc += num_c // 4 print(scc)
s579547290
p03799
u755962107
1487470015
Python
Python (3.4.3)
py
Runtime Error
18
2940
69
u, v = map(int, input().split()) print(min(u//2, (2*u+v)//4))
s656391621
p03799
u755962107
1487469977
Python
Python (3.4.3)
py
Runtime Error
17
3064
60
u, v = map(int, input().split()) print(min(u//2, (2*u+v)//4)
s269560906
p03800
u222668979
1600034109
Python
PyPy3 (7.3.0)
py
Runtime Error
165
68628
503
from itertools import product for bfo2, bfo1 in product(['S', 'W'], repeat=2): ans = [bfo2, bfo1] for i in s: if ((bfo1 == 'S' and i == 'o') or (bfo1 == 'W' and i == 'x')): ans.append(bfo2) elif ((bfo1 == 'S' and i == 'x') or (bfo1 == 'W' and i == 'o')): ans.append(*({'S', 'W'} - {bfo2})) bfo1, bfo2 = ans[-1], bfo1 if ans[:2] == ans[-2:]: print(*ans[1:-1], sep='') break else: print(-1)
s269498164
p03800
u223646582
1591779351
Python
PyPy3 (2.4.0)
py
Runtime Error
208
48964
703
N = int(input()) S = input() C = ('SS', 'SW', 'WS', 'WW') for i in range(4): ans = list(C[i]) for j in range(1, N): if (ans[-1] == 'S' and S[j] == 'o') or(ans[-1] == 'W' and S[j] == 'x'): ans.append(ans[-2]) else: ans.append('S' if ans[-2] == 'W' else 'W') if ans[0] == ans[-1]: ans.remove(-1) if (ans[0] == 'S' and S[0] == 'o' and ans[-1] == ans[1]) or \ (ans[0] == 'S' and S[0] == 'x' and ans[-1] != ans[1]) or \ (ans[0] == 'W' and S[0] == 'o' and ans[-1] != ans[1]) or \ (ans[0] == 'W' and S[0] == 'x' and ans[-1] == ans[1]): print(''.join(ans)) exit() print(-1)
s960272077
p03800
u706159977
1585700159
Python
Python (3.4.3)
py
Runtime Error
17
3444
1247
Menagerien = int(input()) s = input() a = "SS" ct=1 while ct<7: for i in range(n-1): p=a[i] q="A" if a[i]=="S": q="W" else: q="S" if a[i+1]=="S": if s[i+1] == "o": a=a+a[i] else: a=a+q else: if s[i+1] == "o": a=a+q else: a=a+a[i] if a[0]==a[n]: if a[0]=="S" and s[0]=="o" and a[n-1]==a[1]: print(a[0:n]) break elif a[0]=="S" and s[0] !="o" and a[n-1]!=a[1]: print(a[0:n]) break elif a[0]=="W" and s[0] =="o" and a[n-1]!=a[1]: print(a[0:n]) break elif a[0]=="W" and s[0] !="o" and a[n-1]==a[1]: print(a[0:n]) break else: ct=ct+1 if ct==2: a="SW" elif ct==3: a="WS" elif ct==4: a="WW" else: print(-1) break else: ct=ct+1 if ct==2: a="SW" elif ct==3: a="WS" elif ct==4: a="WW" else: print(-1) break
s109443694
p03800
u644907318
1578841192
Python
Python (3.4.3)
py
Runtime Error
196
4340
760
def f(x,y,z): if x=="S" and y=="o": return z if x=="S" and y=="x": return g(z) if x=="W" and y=="o": return g(z) if x=="W" and y=="x": return z def g(x): if x=="S": return "W" if x=="W": return "S" def check(x,y): t[0]=x t[1]=y for j in range(1,N-1): t[j+1] = f(t[j],s[j],t[j-1]) x1 = f(t[N-1],s[N-1],t[N-2]) y1 = f(x1,s[0],t[N-1]) if x==x1 and y==y1: return True else: return False N = int(input()) s = input().strip() t = [0 for _ in range(N)] if check("S","S"): print("".join(t)) elif check("S","W"): print("".join(t)) elif check("W","S"): print("".joint(t)) elif check("W","W"): print("".join(t)) else: print(-1)
s199001146
p03800
u644907318
1578840845
Python
PyPy3 (2.4.0)
py
Runtime Error
214
47856
760
def f(x,y,z): if x=="S" and y=="o": return z if x=="S" and y=="x": return g(z) if x=="W" and y=="o": return g(z) if x=="W" and y=="x": return z def g(x): if x=="S": return "W" if x=="W": return "S" def check(x,y): t[0]=x t[1]=y for j in range(1,N-1): t[j+1] = f(t[j],s[j],t[j-1]) x1 = f(t[N-1],s[N-1],t[N-2]) y1 = f(x1,s[0],t[N-1]) if x==x1 and y==y1: return True else: return False N = int(input()) s = input().strip() t = [0 for _ in range(N)] if check("S","S"): print("".join(t)) elif check("S","W"): print("".join(t)) elif check("W","S"): print("".joint(t)) elif check("W","W"): print("".join(t)) else: print(-1)
s949282473
p03800
u644907318
1578840132
Python
PyPy3 (2.4.0)
py
Runtime Error
220
47856
1051
def f(x,y,z): if x=="S" and y=="o": return z if x=="S" and y=="x": return g(z) if x=="W" and y=="o": return g(z) if x=="W" and y=="x": return z def g(x): if x=="S": return "W" if x=="W": return "S" def check(x,y): t[0]=x t[1]=y for j in range(1,N-1): t[j+1] = f(t[j],s[j],t[j-1]) x1 = f(t[N-1],s[N-1],t[N-2]) y1 = f(x1,s[0],t[N-1]) if x==x1 and y==y1: return True else: return False N = int(input()) s = input().strip() t = [0 for _ in range(N)] if s[0]=="o": if check("S","S"): print("".join(t)) elif check("S","W"): print("".join(t)) elif check("W","S"): print("".joint(t)) elif check("W","W"): print("".join(t)) else: print(-1) else: if check("S","S"): print("".join(t)) elif check("S","W"): print("".join(t)) elif check("W","S"): print("".joint(t)) elif check("W","W"): print("".join(t)) else: print(-1)
s529909752
p03800
u520276780
1578275898
Python
Python (3.4.3)
py
Runtime Error
17
2940
532
import sys n = int(input()) s = input() L = ["SS","SW","WS","WW"] l= len(s) ##0,1に置き換えたりしない ##条件分岐注意する ##ずらす必要はない、Lが固定するのはindexで-2,-1 for t in L:  tmp = t### for i in range(l): if (s[i]=="x") ^ (tmp[-1] == "W"): if tmp[-2]=="S": tmp+= "W" else: tmp += "S" else: tmp += tmp[-2] if tmp[:2]==tmp[-2:]: print(tmp) sys.exit() print(-1)
s429406261
p03800
u518042385
1574227078
Python
Python (3.4.3)
py
Runtime Error
193
7336
904
n=int(input()) w1=list(input()) s="S" w="W" o="o" x="x" l=[[s,s],[s,w],[w,w],[w,s]] for j in range(4): for i in range(1,n): if w1[i]==o: if l[j][-1]==s: if l[j][-2]==s: l[j].append(s) else: l[j].append(w) else: if l[j][-2]==s: l[j].append(w) else: l[j].append(s) else: if l[j][-1]==s: if l[j][-2]==s: l[j].append(w) else: l[j].append(s) else: if l[j][-2]==s: l[j].append(s) else: l[j].append(w) for i in range(4): if l[i][0]==l[i][-1]: del l[i][-1] answer=l[i] b=True break if not b: print(-1) else: print("".join(answer))
s159494874
p03800
u854831509
1571197580
Python
Python (3.4.3)
py
Runtime Error
17
2940
782
#include <bits/stdc++.h> using namespace std; using ll=long long; const ll MOD=(ll)1e9+7; int main() { int N; string s; cin>>N>>s; for (int i = 0; i < 4; ++i) { vector<bool> sheep(N+1,false); sheep[0]=(i&10); sheep[1]=(i&1); for (int i = 2; i <= N; ++i) { if(s[i-1]=='o'){ sheep[i]=!(sheep[i-1]^sheep[i-2]); }else{ sheep[i]=(sheep[i-1]^sheep[i-2]); } } //整合性 if(sheep[0]==sheep[N] && ((s[0] == 'o')^sheep[0]) == (sheep[1] ^ sheep[N - 1])){ for (int j = 0; j < N; ++j) { cout<<((sheep[j])?"S":"W"); } cout<<endl; return 0; } } cout<<-1<<endl; return 0; }
s358671926
p03800
u413165887
1570591271
Python
Python (3.4.3)
py
Runtime Error
17
3064
694
n = int(input()) s = str(input()) s += s[0] candidate = [[1,-1],[1,1],[-1,-1],[-1,1]] result = [] checker = 0 while checker < 4: result = candidate[checker] for i in range(1, n): if s[i] == 'o' and result[i] == 1: result.append(result[-2]) elif s[i] == 'x' and result[i] == 1: result.append(-result[-2]) elif s[i] == 'o' and result[i] == -1: result.append(-result[-2]) else: result.append(result[-2]) if result[0] == result[-1]: checker += 10 else: checker += 1 if checker == 4: print(-1) else: result = ['S' if x == 1 else 'W' for x in result[:n]] print(''.join(result)
s115056303
p03800
u780962115
1570334644
Python
Python (3.4.3)
py
Runtime Error
18
3552
2566
n=int(input()) s=input() flag=True lists=["WWW","SWS","WSS","SSW","SWW","WWS","SSS","WSW"] strings="" if s[0]=="x": j==0 while j<4: strings=lists[j] for i in range(n-1): if strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="o": strings+="S" elif strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="x": strings+="W" elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="o": strings="" break elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="x": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="o": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="x": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="o": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="x": strings+="S" else: break if len(strings)==n+2 and strings[0]==strings[-2] and strings[1]==strings[-1]: flag=False print(strings[1:-1]) strings="" break else: strings="" j+=1 elif s[0]=="o": j==4 while j<8: strings=lists[j] for i in range(n-1): if strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="o": strings+="S" elif strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="x": strings+="W" elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="o": strings="" break elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="x": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="o": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="x": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="o": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="x": strings+="S" else: break if len(strings)==n+2 and strings[0]==strings[-2] and strings[1]==strings[-1]: flag=False print(strings[1:-1]) strings="" break else: strings="" j+=1 if flag==True: print("-1")
s848372402
p03800
u780962115
1570334410
Python
Python (3.4.3)
py
Runtime Error
18
3552
2486
n=int(input()) s=input() flag=True lists=["WWW","SWS","WSS","SSW","SWW","WWS","SSS","WSW"] strings="" if s[0]=="x": j==0 while j<4: strings+=lists[j] for i in range(n-1): if strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="o": strings+="S" elif strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="x": strings+="W" elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="o": strings="" break elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="x": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="o": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="x": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="o": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="x": strings+="S" if len(strings)==n+2 and strings[0]==strings[-2] and strings[1]==strings[-1]: flag=False print(strings[1:-1]) strings="" break else: strings="" j+=1 elif s[0]=="o": j==4 while j<8: strings=lists[j] for i in range(n-1): if strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="o": strings+="S" elif strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="x": strings+="W" elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="o": strings="" break elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="x": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="o": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="x": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="o": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="x": strings+="S" if len(strings)==n+2 and strings[0]==strings[-2] and strings[1]==strings[-1]: flag=False print(strings[1:-1]) strings="" break else: strings="" j+=1 if flag==True: print("-1")
s208960194
p03800
u780962115
1570334239
Python
Python (3.4.3)
py
Runtime Error
18
3560
2461
n=int(input()) s=input() flag=True lists=["WWW","SWS","WSS","SSW","SWW","WWS","SSS","WSW"] strings="" if s[0]=="x": j==0 while j<4: strings+=lists[j] for i in range(n-1): if strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="o": strings+="S" elif strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="x": strings+="W" elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="o": strings="" break elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="x": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="o": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="x": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="o": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="x": strings+="S" if len(strings)==n+2 and strings[0]==strings[-2] and strings[1]==strings[-1]: flag=False print(strings[1:-1]) strings="" break else: j+=1 elif s[0]=="o": j==4 while j<8: strings=lists[j] for i in range(n-1): if strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="o": strings+="S" elif strings[-2]=="W" and strings[-1]=="W" and s[i+1]=="x": strings+="W" elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="o": strings="" break elif strings[-2]=="W" and strings[-1]=="S" and s[i+1]=="x": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="o": strings+="S" elif strings[-2]=="S" and strings[-1]=="S" and s[i+1]=="x": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="o": strings+="W" elif strings[-2]=="S" and strings[-1]=="W" and s[i+1]=="x": strings+="S" if len(strings)==n+2 and strings[0]==strings[-2] and strings[1]==strings[-1]: flag=False print(strings[1:-1]) strings="" break else: j+=1 if flag==True: print("-1")
s971162391
p03800
u350997995
1569041652
Python
Python (3.4.3)
py
Runtime Error
78
4608
1226
N = int(input()) s = input() ans = "" def solve(n, S): global N,s,ans if n<1: solve(n+1, S+"S") solve(n+1, S+"W") elif n<N-1: if S[n]=="S": if s[n]=="o": solve(n+1, S+S[n-1]) elif S[n-1]=="S": solve(n+1, S+"W") else: solve(n+1, S+"S") else: if s[n]=="x": solve(n+1, S+S[n-1]) elif S[n-1]=="S": solve(n+1, S+"W") else: solve(n+1, S+"S") else: if S[n]=="S" and s[n]=="o" and S[n-1]=="W" and S[0]=="W": ans = S elif S[n]=="S" and s[n]=="o" and S[n-1]=="S" and S[0]=="S": ans = S elif S[n]=="S" and s[n]=="x" and S[n-1]=="S" and S[0]=="W": ans = S elif S[n]=="S" and s[n]=="x" and S[n-1]=="W" and S[0]=="S": ans = S elif S[n]=="W" and s[n]=="o" and S[n-1]=="W" and S[0]=="S": ans = S elif S[n]=="W" and s[n]=="o" and S[n-1]=="S" and S[0]=="W": ans = S elif S[n]=="W" and s[n]=="x" and S[n-1]=="S" and S[0]=="S": ans = S elif S[n]=="W" and s[n]=="x" and S[n-1]=="W" and S[0]=="W": ans = S return solve(-1, "") print(ans if len(ans)!=0 else -1)
s220585360
p03800
u480138356
1567116843
Python
Python (3.4.3)
py
Runtime Error
17
2940
1843
def main(): N = int(input()) s = input() # c = ["WS", "SW", "SS", "WW"] c = ["SW", "WS", "SS", "WW"] ok = False for tmp in c: ans = tmp if for i in range(1, N): if s[i] == "o":# oの時 if ans[i-1] == "S" and ans[i] == "S": ans += "S" elif ans[i-1] == "W" and ans[i] == "S": ans += "W" elif ans[i-1] == "S" and ans[i] == "W": ans += "W" elif ans[i-1] == "W" and ans[i] == "W": ans += "S" else:# xの時 if ans[i-1] == "S" and ans[i] == "S": ans += "W" elif ans[i-1] == "W" and ans[i] == "S": ans += "S" elif ans[i-1] == "S" and ans[i] == "W": ans += "S" elif ans[i-1] == "W" and ans[i] == "W": ans += "W" if ans[0] == ans[-1]: if ans[0] == "S": if s[0] == "o": if (ans[-2] == "S" and ans[1] == "S") or (ans[-2] == "W" and ans[1] == "W"): ok = True else: if (ans[-2] == "S" and ans[1] == "W") or (ans[-2] == "W" and ans[1] == "S"): ok = True else: if s[0] == "o": if (ans[-2] == "S" and ans[1] == "W") or (ans[-2] == "W" and ans[1] == "S"): ok = True else: if (ans[-2] == "S" and ans[1] == "S") or (ans[-2] == "W" and ans[1] == "W"): ok = True if ok: print(ans[:-1]) # print(len(ans)) break if not ok: print(-1) if __name__ == "__main__": main()