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
s933075042
p03796
u631914718
1487479427
Python
Python (3.4.3)
py
Runtime Error
2227
114112
224
n = int(input()) import sys sys.setrecursionlimit(100000) def fa(n, memo=dict()): if n==0 or n == 1: return 1 elif n in memo.keys(): return memo[n] else: temp = fa(n-1)*n memo[n] = temp return temp print(fa(n))
s936990273
p03796
u327543932
1487476461
Python
Python (2.7.6)
py
Runtime Error
22
3460
110
n=input() def P(n): if n==1: return 1 else: return P(n-1)*n print int((P(n)%(1e9 +7)))
s509889489
p03796
u327543932
1487476364
Python
Python (2.7.6)
py
Runtime Error
22
3460
105
n=input() def P(n): if n==1: return 1 else: return P(n-1)*n print (P(n)%(1e9 +7))
s474932970
p03796
u327543932
1487476234
Python
Python (2.7.6)
py
Runtime Error
22
3460
105
n=input() def P(n): if n==1: return 1 else: return P(n-1)*n print (P(n)/(1e9 +7))
s415749245
p03796
u327543932
1487476107
Python
Python (2.7.6)
py
Runtime Error
22
3460
96
n=input() def P(n): if n==1: return 1 else: return P(n-1)*n print (P(n))
s569708002
p03796
u820315626
1487474271
Python
Python (3.4.3)
py
Runtime Error
229
3980
73
import math n = int(input()) print(math.factorial(n) / (pow(10, 9) + 7))
s876126724
p03796
u811388439
1487472255
Python
Python (3.4.3)
py
Runtime Error
17
2940
142
def sunuke_f2(n): power = 1 for i in range(1, n+1, 1): power *= i i += 1 print(power % (10 ** 9 + 7)) sunuke_f2(N)
s412261247
p03796
u631914718
1487470164
Python
Python (3.4.3)
py
Runtime Error
72
4140
202
def f(n, memo = dict()): if n == 0 or n == 1: return 1 elif n in memo.keys(): return memo[n] else: temp = (f(n-1) * n) % int(10e9+7) memo[n] = temp return temp n = int(input()) print(f(n))
s055255153
p03797
u666550725
1599859543
Python
PyPy3 (7.3.0)
py
Runtime Error
358
94488
91
N, M = map(int, input()) if N * 2 >= M: print(M // 2) else: print(N + (M - N * 2) // 3)
s924417473
p03797
u235210692
1598917744
Python
Python (3.8.2)
py
Runtime Error
25
9088
225
n, m = [int(i) for i in input().split()] if n >= 2 * m: print(m // 2) else: print(n + (m - 2 * n) // 2) n, m = [int(i) for i in input().split()] if n >= 2 * m: print(m // 2) else: print(n + (m - 2 * n) // 4)
s299915565
p03797
u235210692
1598917639
Python
Python (3.8.2)
py
Runtime Error
27
9068
226
n, m = [int(i) for i in input().split()] if n >= 2 * m: print(m // 2) else: print(n + (m - 2 * n) // 2) n, m = [int(i) for i in input().split()] if n >= 2 * m: print(m // 2) else: print(n + (m - 2 * n) // 4)
s196469549
p03797
u752774573
1597809736
Python
PyPy3 (7.3.0)
py
Runtime Error
93
74628
66
N,M=list(map(int, input().split())) K=N-2*M print(max(N+K//3,N))
s391383717
p03797
u909716307
1597613335
Python
Python (3.8.2)
py
Runtime Error
26
9104
65
n,m=map(int,input().split()) c=n%(m//2) d=m-2*c c+=d//4 print(c)
s269417545
p03797
u334700364
1594713000
Python
Python (3.8.2)
py
Runtime Error
22
9044
141
n, m = map(int, input()) possible_c = m possible_s = n * 2 one_valid = 4 result = (possible_c + possible_s) // one_valid print (result)
s248038848
p03797
u001577246
1589391835
Python
Python (3.4.3)
py
Runtime Error
17
2940
47
n=int(input()) m=int(input()) print((2*n+m)//4)
s407111859
p03797
u519923151
1589128343
Python
Python (3.4.3)
py
Runtime Error
18
2940
119
n,m = map(int, input().split()) if n*2 <= m: ma = m-n*2 ans = n+(ma//4) else: ans = ma//2 print(ans)
s531986249
p03797
u633450100
1588290404
Python
Python (3.4.3)
py
Runtime Error
17
2940
352
N,M = [int(i) for i in input().split()] count = 0 if 2 * N <= M: count = N M -= 2 * N if M >= 4: count += M // 4 print(count) else: print(count) else: if N != 0: while N == 0 or M <= 1: count += 1 N -= 1 M - = 2 print(count) else: print(count)
s029854479
p03797
u633450100
1588290374
Python
Python (3.4.3)
py
Runtime Error
17
2940
352
N,M = [int(i) for i in input().split()] count = 0 if 2 * N <= M: count = N M -= 2 * N if M >= 4: count += M // 4 print(count) else: print(count) else: if N != 0: while N == 0 or M <= 1: count += 1 N -= 1 M - = 2 print(count) else: print(count)
s777633149
p03797
u189479417
1587611581
Python
Python (3.4.3)
py
Runtime Error
17
2940
110
N, M = map(int,input().split()) if 2 * N >= M: print(M // 2) else: k = M - 2 * S print(S + k // 4)
s535614873
p03797
u149991748
1587419366
Python
Python (3.4.3)
py
Runtime Error
17
2940
123
n, m = map(int, input().split()) if n*2 < m: c = m - (n*2) ans = int(c/4) + n else: ans = int(c/2) print(ans)
s706139005
p03797
u230717961
1587088681
Python
Python (3.4.3)
py
Runtime Error
18
2940
201
def slove(n, m): tmp = n if n < m // 2 else m // 2 tmp2 = (m - tmp * 2) // 4 return tmp + tmp2 if __name__ == "__main__": n, m = [i for i in input().split()] print(slove(n, m))
s762760276
p03797
u482157295
1585968197
Python
Python (3.4.3)
py
Runtime Error
17
2940
196
n = int(input()) ans = 1 dummy1,dummy2 = divmod(n,2) for i in range(1,dummy1+1): ans *= i ans *= n+1-i ans = ans % (10**9+7) if dummy2 == 1: ans = ((dummy1+1)*ans % (10**9+7)) print(ans)
s757637732
p03797
u089142196
1585084117
Python
Python (3.4.3)
py
Runtime Error
17
2940
89
N,M=map(int,input().split()) O = M//2 if N>=O: print(N) elpe: P = (N+O)//2 print(P)
s373459612
p03797
u263824932
1583564109
Python
Python (3.4.3)
py
Runtime Error
19
2940
199
N,M=map(int,input().split()) count=0 if N>=1 and M>=2: a=M//2 if N>=a: M=M-2*a answer=a else: M=M-2*N answer=N if M>=4: kotae=M//4 print(answer+kotae)
s556079643
p03797
u349091349
1582767881
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38384
71
n,m=map(int,input().split()) print(min(n , (m - 2*i)//2) + (m-2*n)//4)
s114262202
p03797
u823044869
1579908701
Python
Python (3.4.3)
py
Runtime Error
17
2940
95
n,m = map(int,input().split()) if 2*n <= m: print(n+(m-2*n)//4) elif 2*n > m: print(c//2)
s030621989
p03797
u386089355
1578445155
Python
Python (3.4.3)
py
Runtime Error
17
2940
105
n, m = map(int, input().split()) if 2 * n >= m: print(min(n, m//2) else: print((2 * n + m) // 4)
s120830974
p03797
u807084817
1578183261
Python
PyPy3 (2.4.0)
py
Runtime Error
183
38896
199
def resolve(): s,c= map(int,input().split()) if s>=c/2: print(str(math.floor(c/2))) else: zanc = c - (s * 2) print(str(s + math.floor(zanc/4))) resolve()
s730937589
p03797
u557494880
1573998920
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38384
114
N,M = map(int,input().split()) a = M - 2*N if a <= 0: ans = C//2 else: a = a//4 ans = N + a print(ans)
s583885634
p03797
u876688988
1572907436
Python
Python (2.7.6)
py
Runtime Error
10
2568
220
s,c = map(int, input().split()) cnt = 0 while(True): if(c > 2): if(s > 0): s = s - 1 c = c - 2 else: c = c - 3 cnt = cnt + 1 else: break
s159301260
p03797
u033606236
1568989813
Python
Python (3.4.3)
py
Runtime Error
17
2940
83
S,C = map(int,input().split()) if C >= S*2:ans = S ans += (C-ans*2) // 4 print(ans)
s387602279
p03797
u703890795
1567076201
Python
Python (3.4.3)
py
Runtime Error
17
2940
66
N, M = map(int, input().split()) M2 += N*2 print(min(M2//4, M//2))
s423531617
p03797
u777283665
1565563021
Python
PyPy3 (2.4.0)
py
Runtime Error
182
38256
68
if c < 2 * s: print(c // 2) else: c -= 2 * s print(s + c // 4)
s115159414
p03797
u670180528
1565245867
Python
Python (3.4.3)
py
Runtime Error
18
2940
63
n,m=map(int,input().split()) print(min(s,c//2)+max(0,c-s*2)//4)
s275515790
p03797
u695079172
1564966383
Python
Python (3.4.3)
py
Runtime Error
17
2940
383
s,c = map(int,input().split(" ")) counter = 0 if s >= 1 and c >= 2: temp = min(s,c//2) s -= temp c -= temp * 2 counter += temp #print("s:",s) #print("c:",c) #print("counter:",counter) if s<=0 and c >= 4: temp = c // 4 counter += temp c -= temp #print("s:",s) #print("c:",c) #print("counter:",counter) print(temp)
s643974198
p03797
u695079172
1564966277
Python
Python (3.4.3)
py
Runtime Error
17
3060
377
s,c = map(int,input().split(" ")) counter = 0 if s >= 1 and c >= 2: temp = min(s,c//2) s -= temp c -= temp * 2 counter += temp print("s:",s) print("c:",c) print("counter:",counter) if s<=0 and c >= 4: temp = c // 4 counter += temp c -= temp print("s:",s) print("c:",c) print("counter:",counter) print(temp)
s005851268
p03797
u695079172
1564966232
Python
Python (3.4.3)
py
Runtime Error
20
3316
377
s,c = map(int,input().split(" ")) counter = 0 if s >= 1 and c >= 2: temp = min(s,c//2) s -= temp c -= temp * 2 counter += temp print("s:",s) print("c:",c) print("counter:",counter) if s<=0 and c >= 4: temp = c // 4 counter += temp c -= temp print("s:",s) print("c:",c) print("counter:",counter) print(temp)
s425381056
p03797
u695079172
1564966061
Python
Python (3.4.3)
py
Runtime Error
17
2940
214
s,c = map(int,input().split(" ")) counter = 0 if s >= 1 and c >= 2: temp = min(s,c//2) s -= temp c -= temp counter += temp if s<=0 and c >= 4: temp = c // 4 counter += temp c -= temp print(temp)
s937363185
p03797
u552122040
1562024519
Python
Python (3.4.3)
py
Runtime Error
17
2940
158
n = int(input()) power = [1] if n == 1: print(1) exit() for i in range(2, n+1): power.append((i * power[-1]) % (10 ** 9 + 7)) print(power[-1])
s592786883
p03797
u552122040
1562024490
Python
Python (3.4.3)
py
Runtime Error
17
2940
158
n = int(input()) power = [1] if n == 1: print(1) exit() for i in range(2, n+1): power.append((i * power[-1]) % (10 ** 9 + 7)) print(power[-1])
s399109873
p03797
u552122040
1562024454
Python
Python (3.4.3)
py
Runtime Error
18
3068
158
n = int(input()) power = [1] if n == 1: print(1) exit() for i in range(2, n+1): power.append((i * power[-1]) % (10 ** 9 + 7)) print(power[-1])
s732717797
p03797
u403660920
1559019602
Python
Python (3.4.3)
py
Runtime Error
17
2940
129
List=[int(j) for j in input().split()] a=List[1] b=List[2] if b>2*a: c=b-2*a d=c//4 print(a+d) else: print(b//2)
s966625128
p03797
u403660920
1559019399
Python
Python (3.4.3)
py
Runtime Error
17
2940
121
List=input().split() a=int(List[1]) b=int(List[2]) if b>2*a: c=b-2*a d=c//4 print(a+d) else: print(b//2)
s753559818
p03797
u403660920
1559019018
Python
Python (3.4.3)
py
Runtime Error
17
2940
91
a,b=input().split() if b>2*a: c=b-2*a d=c//4 print(a+d) else: print(b//2)
s805119859
p03797
u403660920
1559018890
Python
Python (3.4.3)
py
Runtime Error
17
2940
95
a,b=int(input().split()) if b>2*a: c=b-2*a d=c//4 print(a+d) else: print(b//2)
s532286189
p03797
u403660920
1559018719
Python
Python (3.4.3)
py
Runtime Error
17
2940
69
a=int(input()) b=int(input()) c=b-2*a d=c//4 print(a+d)
s009649707
p03797
u403660920
1559018660
Python
Python (3.4.3)
py
Runtime Error
17
2940
100
a=int(input()) b=int(input()) if b>2*a: c=b-2*a d=c//4 print(a+d) else: print(b//2)
s806422349
p03797
u113711423
1555951489
Python
Python (3.4.3)
py
Runtime Error
2104
2940
170
N, M = map(int, input().split()) for scc in range(M//2, -1, -1): excess_c = M - scc*2 if excess_c//2 + N >= scc: print(scc) sys.exit(0) print(0)
s364241109
p03797
u619458041
1555277816
Python
Python (3.4.3)
py
Runtime Error
18
3056
333
import sys def main(): input = sys.stdin.readline N, M = map(int, input().split()) if N >= M // 2: ans = M // 2 S -= M // 2 ans += S // 2 return ans else: ans = N M -= 2 * N ans += M // 4 return ans if __name__ == '__main__': print(main())
s716783543
p03797
u677440371
1554870229
Python
Python (3.4.3)
py
Runtime Error
20
2940
152
N, M = map(int, input().split()) if 2 * N <= M: ans1 = N M -= ans1 * 2 # print(ans1) # print(M) ans2 = M // 4 # print(ans2) print(ans1 + ans2)
s733000504
p03797
u707498674
1553813080
Python
Python (3.4.3)
py
Runtime Error
17
2940
70
N, M = map(int, input().split()) temp = N * 2 + M print(temp // 4)
s066776061
p03797
u766684188
1550787593
Python
Python (3.4.3)
py
Runtime Error
17
2940
115
n,m=map(int,input().split()) print((n+m//2)//2)n,m=map(int,input().split()) m//=2 print((n+(m-n)//2) if n<m else m)
s893833395
p03797
u106297876
1548732131
Python
Python (3.4.3)
py
Runtime Error
18
2940
139
N,M = map(int,input().split()) ans = 0 #S型をN個を使い切る if 2*N <= M: M -= 2*N ans += N #C型で作る ans += //4 print(ans)
s338517542
p03797
u643840641
1545521249
Python
Python (3.4.3)
py
Runtime Error
17
2940
71
n, m = map(int, input()) print(n + max(0, (m-2*n)//4) if m>=2 else "0")
s800275080
p03797
u643840641
1545521215
Python
Python (3.4.3)
py
Runtime Error
18
2940
69
n, m = map(int, input()) print(n + max(0, (m-2*n)//4) if m>=2 else 0)
s204246841
p03797
u111365959
1543850130
Python
Python (3.4.3)
py
Runtime Error
18
3064
69
n,m = [int(x) for x in input().split()] c = n if m - n >= 0 else pass
s603872987
p03797
u037098269
1542228066
Python
Python (3.4.3)
py
Runtime Error
18
2940
174
n, m = map(int, input().split()) if m >= n*2: leave_c = m - n*2 available = leave_c // 4 print(n + available) else: availabe_c = m // 2 print(available_c)
s468752530
p03797
u940102677
1539291348
Python
Python (3.4.3)
py
Runtime Error
17
2940
88
n, m = map(int, input().split()) if m <= 2*n: print(m//2) else: print((m-2n)//3 + n)
s296559587
p03797
u115682115
1532903387
Python
Python (3.4.3)
py
Runtime Error
17
2940
133
s,c = map(int,input().split()) if s<c/2: c_s = (c-2*s)//4 sc = s print(c_s+sc) else: sc = (min(s,c//2) print(sc)
s997157899
p03797
u698479721
1529379263
Python
Python (3.4.3)
py
Runtime Error
17
2940
98
N,M = map(int, input().split()) s = N c = M if 2*N>=M: print(M//2) else: t = 2*s+c print(t//4)
s046090668
p03797
u856232850
1524355903
Python
Python (3.4.3)
py
Runtime Error
17
2940
57
if s >= c//2: print(c//2) else: print((2*s+c)//4)
s770219642
p03797
u503901534
1523598209
Python
Python (3.4.3)
py
Runtime Error
17
2940
194
n , m = list(map(int,input().split())) counter = 0 if n < m // 2: counter = n m = m - 2* n else: counter = m //2 n = n - m //2 counter = counter + m //4 print(count)
s422337894
p03797
u846150137
1521315885
Python
Python (3.4.3)
py
Runtime Error
17
2940
164
s,c=[int(i) for i in input().split()] def cul(s,c): if s >= c // 2: x = s c = c - s * 2, 0 x += c//4 else: x = c//2 return x print(cul(s,c))
s547040163
p03797
u735154525
1504647490
Python
Python (2.7.6)
py
Runtime Error
10
2568
225
n , m = map(int, raw_input().split()) tmp = m - (2 * n) ans = 0 if tmp < 0: tmp = m - 2 * (n - tmp) if tmp >= 0: n -= n - tmp break m = tmp ans += n ans += tmp / 4 print ans
s047008577
p03797
u735154525
1504647330
Python
Python (2.7.6)
py
Runtime Error
3113
6512
276
n , m = map(int, raw_input().split()) tmp = m - (2 * n) ans = 0 if tmp < 0: for i in range(n): tmp = m - 2 * (n - i) if tmp >= 0: n -= i break m = tmp ans += n ans += tmp / 4 print ans
s656829969
p03797
u667084803
1494530501
Python
Python (3.4.3)
py
Runtime Error
17
3060
150
S,C=map(int,input().split()) if C<2*S: print(int(C/2)) else: if (C-2*S)%4==0: k=(C-2*S)/4 else: k=int(1+(C-2*S)/4) print(int((C-2*k)/2))
s901496312
p03797
u162172626
1488834784
Python
Python (3.4.3)
py
Runtime Error
17
2940
82
n,m = gets.chomp.split.map(&:to_i) if n > m / 2 p m / 2 else p (m+2*n) / 4 end
s020827972
p03797
u503813943
1488735815
Python
Python (3.4.3)
py
Runtime Error
17
2940
77
s,c = map(int,input()) if c/2 <= s: print(c//2) else: print(s + (c-s*2)//4)
s569888591
p03797
u873904588
1488504317
Python
Python (3.4.3)
py
Runtime Error
17
2940
154
import math N,M = map(int,input().split()) count = 0 if N*2>M: count = math.floor(M/2) else: temp=M-2*N ans = N+math.floor(temp/4) print(ans)
s932195549
p03797
u873904588
1488504251
Python
Python (3.4.3)
py
Runtime Error
17
2940
160
import math N,M = map(int,input().split()) count = 0 if N*2>M: count = math.floor(M/2) else: temp=M-2*N ans = N+math.floor(temp/4) print(ans)
s124001355
p03797
u481333386
1487662419
Python
Python (3.4.3)
py
Runtime Error
17
2940
188
s, c = [int(e) for e in input().split()] def main(s, c): ret = 0 for i in range(s): ret += 1 c -= 2 ret += c // 4 return ret ans = main(n) print(ans)
s647114751
p03797
u622011073
1487482733
Python
Python (3.4.3)
py
Runtime Error
17
2940
71
n,m=map(int,input().split()) a=n%(m//2) m-=2*a if m<0:m=0 print(a+m//4)
s802691308
p03797
u622011073
1487482468
Python
Python (3.4.3)
py
Runtime Error
17
2940
59
n,m=map(int,input().split()) a=n%(m//2) print(a+(m-2*a)//4)
s350400767
p03797
u811388439
1487475127
Python
Python (3.4.3)
py
Runtime Error
18
2940
181
def sunuke_f3(n, m) : if n >= m : return(m//2) else : if 2*n < m : return(n + (m-2*n)//4) else : return(m//2) sunuke_f3(N, M)
s115901622
p03797
u631914718
1487474430
Python
Python (3.4.3)
py
Runtime Error
17
3192
1442
# if a > b return true def compare(a, b): # a also b are both string l = max(len(a), len(b)) a_ = a.rjust(l, '0') b_ = b.rjust(l, '0') return a_ > b_ def divide(num, den): # den is integer quo = ''; resi = 0 digit = len(num) if int(num[0]) >= den else len(num)-1 for i in range(len(num)): temp = (int(num[i])+resi*10)//den # print('temp', temp) resi = (int(num[i])+resi*10)%den # print('resi', resi) quo += str(temp) if temp != 0 else '' return quo.ljust(digit, '0') def multi(a, n): s = ''; resi = 0 for i in range(len(a))[::-1]: temp = (int(a[i])*n + resi)%10 # print('temp', temp) resi = (int(a[i])*n + resi)//10 # print('resi', resi) s = str(temp) + s return s def plus(a, b): l = max(len(a), len(b)) a_ = a.rjust(l, '0') b_ = b.rjust(l, '0') s = ''; resi = 0 for i in range(l)[::-1]: temp = (int(a_[i]) + int(b_[i]) + resi)%10 # print('temp', temp) resi = (int(a_[i]) + int(b_[i]) + resi)//10 # print('resi', resi) s = str(temp) + s return s # a is higher than b def minus(a, b): l = max(len(a), len(b)) a_ = a.rjust(l, '0') b_ = b.rjust(l, '0') s = ''; bollow = 0 for i in range(l)[::-1]: temp = int(a_[i]) - int(b_[i]) - bollow # print('temp', temp) bollow = 0 if temp >= 0: s = str(temp) + s else: bollow = 1 s = str(temp + 10) + s return s if compare(s, divide(c, 2)) or s == c: print(divide(c, 2)) else: print(plus(s, divide(minus(c, multi(s, 2)), 4)))
s387365997
p03797
u846552659
1487471609
Python
Python (3.4.3)
py
Runtime Error
17
2940
168
#include <stdio.h> int main(void){ long long int N, M; scanf("%lld %lld", &N, &M); long long int ans = (N+M/2)/2; printf("%lld\n", ans); return 0; }
s505092773
p03797
u562120243
1487471569
Python
Python (3.4.3)
py
Runtime Error
17
2940
173
import math Sc = input().split() Scc = int(Sc[1])/4 math.floor(Scc) for i in range(int(Sc[0])): if int(Sc[1])%4 == 2*int(Sc[0]): Scc+=1 math.floor(Scc) print(Scc
s444140106
p03797
u631914718
1487470497
Python
Python (3.4.3)
py
Runtime Error
17
2940
85
s, c = map(int, ip().split()) if s >= c//2: print(c//2) else: print(s + (c-s*2)//4)
s591459725
p03798
u074220993
1597516969
Python
Python (3.8.2)
py
Runtime Error
31
9284
534
N = int(input()) s = input() init = ["SS", "SW","WS","WW"] next_animal = { ("S","o","S"):"S", ("S","o","W"):"W", ("S","x","S"):"W", ("S","x","W"):"S", ("W","o","S"):"W", ("W","o","W"):"S", ("W","x","S"):"S", ("W","x","W"):"W "} for X in init: SW = X for i in range(1,N): SW += next_animal[SW[i],s[i],SW[i-1]] if SW[0] == SW[len(SW)-1]: print(SW[:len(SW)-1]) break else: print(-1)
s074147582
p03798
u786020649
1595277791
Python
Python (3.8.2)
py
Runtime Error
138
13224
555
import sys from collections import deque dic={'o':lambda s:1-(s[1]^s[0]), 'x':lambda s:s[1]^s[0]} def mknseq(ox,ld): for x in ld: x.append(dic[ox]((x[-2],x[-1]))) def main(): N=int(sys.stdin.readline().strip()) s=list(sys.stdin.readline().strip()) ans=[deque([x,y]) for x in range(2) for y in range(2)] for x in range(N): mknseq(s[x],ans) # print(ans) for x in ans: if x[:2]==x[-2:]: return print(''.join([['W','S'][i] for i in x])[1:-1]) print(-1) if __name__=='__main__': main()
s906618858
p03798
u514687406
1593820024
Python
Python (3.8.2)
py
Runtime Error
52
11996
355
# import sys;input = lambda : sys.stdin.readline() n = int(input()) s = input() x=[] ans=["s"]*n for i in range(n): if s[i]=='x': x.append(i) if len(x)>1: for i in range(0,len(x),2): ans[x[i]+1:x[i+1]]=["w"]*(x[i+1]-x[i]-1) print(("".join(ans)).upper()) elif len(x)==1: print(-1) elif len(x)==0: print(("s"*n).upper())
s767291159
p03798
u098012509
1590544702
Python
Python (3.4.3)
py
Runtime Error
79
4780
1671
import sys input = sys.stdin.readline def main(): N = int(input()) S = input().strip() def solve(current_index, ans): if current_index <= 0: solve(current_index + 1, ans + "S") solve(current_index + 1, ans + "W") elif current_index == N - 1: if ans[-1] == "S": if S[current_index] == 'o': if ans[-2] == ans[0]: print(ans) exit() else: if ans[-2] != ans[0]: print(ans) exit() else: if S[current_index] == 'x': if ans[-2] == ans[0]: print(ans) exit() else: if ans[-2] != ans[0]: print(ans) exit() else: if ans[-1] == "S": if S[current_index] == 'o': solve(current_index + 1, ans + ans[-2]) else: if ans[-2] == "S": solve(current_index + 1, ans + "W") else: solve(current_index + 1, ans + "S") else: if S[current_index] == 'x': solve(current_index + 1, ans + ans[-2]) else: if ans[-2] == "S": solve(current_index + 1, ans + "W") else: solve(current_index + 1, ans + "S") solve(-1, "") print(-1) if __name__ == '__main__': main()
s567918957
p03798
u098012509
1590544361
Python
Python (3.4.3)
py
Runtime Error
80
4776
1658
import sys input = sys.stdin.readline def main(): N = int(input()) S = input().strip() def solve(current_index, ans): if current_index == 0: solve(1, ans + "S") solve(1, ans + "W") elif current_index == N - 1: if ans[-1] == "S": if S[current_index] == 'o': if ans[-2] == ans[0]: print(ans) exit() else: if ans[-2] != ans[0]: print(ans) exit() else: if S[current_index] == 'x': if ans[-2] == ans[0]: print(ans) exit() else: if ans[-2] != ans[0]: print(ans) exit() else: if ans[-1] == "S": if S[current_index] == 'o': solve(current_index + 1, ans + ans[-2]) else: if ans[-2] == "S": solve(current_index + 1, ans + "W") else: solve(current_index + 1, ans + "S") else: if S[current_index] == 'x': solve(current_index + 1, ans + ans[-2]) else: if ans[-2] == "S": solve(current_index + 1, ans + "W") else: solve(current_index + 1, ans + "S") solve(0, "S") solve(0, "W") print(-1) if __name__ == '__main__': main()
s020872931
p03798
u588794534
1589980620
Python
PyPy3 (2.4.0)
py
Runtime Error
2112
135332
990
n=int(input()) s=input() def rev(x): if x=="S": return "W" else: return "S" def wolfsheep(xy): global n,s result=[xy[0],xy[1]] for i in range(1,n+1): if result[i]=="S": s+=s[0] if s[i]=="o": result.append(result[i-1]) else: result.append(rev(result[i-1])) else: if s[i]=="o": result.append(rev(result[i-1])) else: result.append(result[i-1]) if result[0]==result[n] and result[1]==result[n+1]: return result else: return 0 #SWパターン tmp= wolfsheep("SW") if tmp!=0: print("".join(tmp[:-2])) exit() #SSパターン tmp= wolfsheep("SS") if tmp!=0: print("".join(tmp[:-2])) exit() #WWパターン tmp= wolfsheep("WW") if tmp!=0: print("".join(tmp[:-2])) exit() #WSパターン tmp= wolfsheep("WS") if tmp!=0: print("".join(tmp[:-2])) exit() print(-1)
s297887316
p03798
u588794534
1589980584
Python
PyPy3 (2.4.0)
py
Runtime Error
2111
135884
990
n=int(input()) s=input() def rev(x): if x=="S": return "W" else: return "S" def wolfsheep(xy): global n,s result=[xy[0],xy[1]] for i in range(1,n+1): if result[i]=="S": s+=s[0] if s[i]=="o": result.append(result[i-1]) else: result.append(rev(result[i-1])) else: if s[i]=="o": result.append(rev(result[i-1])) else: result.append(result[i-1]) if result[0]==result[n] and result[1]==result[n+1]: return result else: return 0 #SWパターン tmp= wolfsheep("SW") if tmp!=0: print("".join(tmp[:-2])) exit() #SSパターン tmp= wolfsheep("SS") if tmp!=0: print("".join(tmp[:-2])) exit() #WWパターン tmp= wolfsheep("WW") if tmp!=0: print("".join(tmp[:-2])) exit() #WSパターン tmp= wolfsheep("WS") if tmp!=0: print("".join(tmp[:-2])) exit() print(-1)
s139899427
p03798
u588794534
1589980516
Python
PyPy3 (2.4.0)
py
Runtime Error
187
47088
970
n=int(input()) s=input() def rev(x): if x=="S": return "W" else: return "S" def wolfsheep(xy): global n,s result=[xy[0],xy[1]] for i in range(1,n+1): if result[i]=="S": if s[i]=="o": result.append(result[i-1]) else: result.append(rev(result[i-1])) else: if s[i]=="o": result.append(rev(result[i-1])) else: result.append(result[i-1]) if result[0]==result[n] and result[1]==result[n+1]: return result else: return 0 #SWパターン tmp= wolfsheep("SW") if tmp!=0: print("".join(tmp[:-2])) exit() #SSパターン tmp= wolfsheep("SS") if tmp!=0: print("".join(tmp[:-2])) exit() #WWパターン tmp= wolfsheep("WW") if tmp!=0: print("".join(tmp[:-2])) exit() #WSパターン tmp= wolfsheep("WS") if tmp!=0: print("".join(tmp[:-2])) exit() print(-1)
s756784406
p03798
u203843959
1589337717
Python
Python (3.4.3)
py
Runtime Error
178
5840
1609
import sys N=int(input()) slist=[x=="o" for x in input()] #print(slist) answer_list=[0]*(N+1) if N==3: if slist.count(True)==3: print("SSS") elif slist.count(False)==3: print("WWW") else: print(-1) sys.exit(0) ok=False for p1,p2 in [(1,1),(1,-1),(-1,1),(-1,-1)]: answer_list[1]=p1 answer_list[2]=p2 if slist[1]: answer_list[3]=answer_list[1] else: answer_list[3]=-answer_list[1] for i in range(3,N+1): l=i-1 r=i%N+1 si=slist[i-1] if answer_list[i]==1: if si: if answer_list[l]==1: answer_list[r]=1 else: answer_list[r]=-1 else: if answer_list[l]==1: answer_list[r]=-1 else: answer_list[r]=1 elif answer_list[i]==-1: if si: if answer_list[l]==1: answer_list[r]=-1 else: answer_list[r]=1 else: if answer_list[l]==-1: answer_list[r]=1 else: answer_list[r]=-1 contra=False if slist[0]: if answer_list[1]==1 and answer_list[2]!=answer_list[N]: contra=True if answer_list[1]==-1 and answer_list[2]==answer_list[N]: contra=True elif not slist[0]: if anser_list[1]==1 and answer_list[2]==answer_list[N]: contra=True if anser_list[1]==-1 and answer_list[2]!=answer_list[N]: contra=True if not contra: ok=True break if ok: #print(answer_list[1:]) sw_list=[] for i in range(1,N+1): if answer_list[i]==1: sw_list.append("S") else: sw_list.append("W") print("".join(sw_list)) else: print(-1)
s592595728
p03798
u977193988
1589125938
Python
Python (3.4.3)
py
Runtime Error
1585
4764
1991
import sys import queue def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(20000000) MOD = 10 ** 9 + 7 def main(): N = int(input()) s = input() Animal = ["WW", "WS", "SS", "SW"] for i in range(1, N - 1): if s[i] == "o": for j in range(4): if Animal[j][-1] == "S": Animal[j] = Animal[j] + Animal[j][-2] else: if Animal[j][-2] == "S": Animal[j] = Animal[j] + "W" else: Animal[j] = Animal[j] + "S" else: for j in range(4): if Animal[j][-1] == "S": if Animal[j][-2] == "S": Animal[j] = Animal[j] + "W" else: Animal[j] = Animal[j] + "S" else: Animal[j] = Animal[j] + Animal[j][-2] for i in range(4): animal = Animal[i] if s[-1] + s[0] == "xo": for a in ["WWWS", "WSSS", "SWSW", "SSWW"]: if animal[-2:] + animal[:2] == a: print(animal) return else: continue elif s[-1] + s[0] == "xx": for a in ["WWWW", "WSSW", "SWSS", "SSWS"]: if animal[-2:] + animal[:2] == a: print(animal) return else: continue elif s[-1] + s[0] == "ox": for a in ["WWSS", "WSWS", "SSSW", "SWWW"]: if animal[-2:] + animal[:2] == a: print(L) return elif s[-1] + s[0] == "oo": for a in ["WWSW", "WSWW", "SSSS", "SWWS"]: if animal[-2:] + animal[:2] == a: print(animal) return else: continue print(-1) if __name__ == "__main__": main()
s547184415
p03798
u064963667
1587997368
Python
Python (3.4.3)
py
Runtime Error
61
4212
1529
n = int(input()) s = input() s = [s[i] for i in range(n)] answer = '' current = 'S' # 1: sheep, -1: wolf first_flag = False for i,l in enumerate(s): if current == 'S': if l == 'x': if first_flag == False: answer += current current = 'W' first_flag = True else: answer += current first_flag = False else: answer += current elif current == 'W': if l == 'x': answer += current else: if first_flag == False: answer += current current = 'S' first_flag = True else: answer += current first_flag = False if answer[0] == 'S': if s[0] == 'o': if answer[1] != answer[-1]: answer = -1 elif s[0] == 'x': if answer[1] == answer[-1]: answer = -1 elif answer[0] == 'W': if s[0] == 'x': if answer[1] != answer[-1]: answer = -1 elif s[0] == 'o': if answer[1] == answer[-1]: answer = -1 if answer[-1] == 'S': if s[-1] == 'o': if answer[1] != answer[-2]: answer = -1 elif s[-1] == 'x': if answer[1] == answer[-2]: answer = -1 elif answer[-1] == 'W': if s[-1] == 'x': if answer[1] != answer[-2]: answer = -1 elif s[-1] == 'o': if answer[1] == answer[-2]: answer = -1 print(answer)
s056038782
p03798
u111555888
1585236619
Python
Python (3.4.3)
py
Runtime Error
96
8080
1921
n=int(input()) s=str(input()) l=[0]*n flag=1 if s[0]=='x': flag=0 new_s='' for j in range(n): if s[j]=='x': new_s+='o' else: new_s+='x' s=new_s def check(i,l): if i==0: l11=[0]*n l12=[0]*n l21=[0]*n l22=[0]*n l11[0]='S' l11[1]=l11[n-1]='S' l12[0]='S' l12[1]=l12[n-1]='W' tmp1=check(i+1,l11) tmp2=check(i+1,l12) l21[0]=l21[n-1]='W' l21[1]='S' l22[0]=l22[1]='W' l22[n-1]='S' tmp3=check(i+1,l21) tmp4=check(i+1,l22) if tmp1==tmp2==tmp3==tmp4==-1: return -1 else: if tmp1!=-1: return tmp1 if tmp2!=-1: return tmp2 if tmp3!=-1: return tmp3 if tmp4!=-1: return tmp4 elif 1<=i<=n-2: if s[i]=='o': if l[i]=='S': l[i+1]=l[i-1] return check(i+1,l) else: if l[i-1]=='W': l[i+1]='S' return check(i+1,l) else: l[i+1]='W' return check(i+1,l) else: if l[i]=='W': l[i+1]=l[i-1] return check(i+1,l) else: if l[i-1]=='S': l[i+1]='W' return check(i+1,l) else: l[i+1]='S' return check(i+1,l) else: if s[i]=='o': if l[i]=='S': if l[i-1]==l[0]: return l else: return -1 else: if l[i-1]!=l[0]: return l else: return -1 else: if l[i]=='S': if l[i-1]!=l[0]: return l else: return -1 else: if l[i-1]==l[0]: if l[0]=='W' and l[i]==l[1]: return -1 else: return l else: return -1 ans=check(0,l) if ans==-1: print(-1) else: if flag: print(''.join(ans)) else: for i in range(n): if ans[i]=='S': ans[i]='W' else: ans[i]='S' print(''.join(ans))
s370622633
p03798
u111555888
1585236119
Python
Python (3.4.3)
py
Runtime Error
100
8104
2092
n=int(input()) s=str(input()) l=[0]*n flag=1 if s[0]=='x': flag=0 def check(i,l): if i==0: l11=[0]*n l12=[0]*n l21=[0]*n l22=[0]*n if s[i]=='o': l11[0]='S' l11[1]=l11[n-1]='S' l12[0]='S' l12[1]=l12[n-1]='W' tmp1=check(i+1,l11) tmp2=check(i+1,l12) l21[0]=l21[n-1]='W' l21[1]='S' l22[0]=l22[1]='W' l22[n-1]='S' tmp3=check(i+1,l21) tmp4=check(i+1,l22) if tmp1==tmp2==tmp3==tmp4==-1: return -1 else: if tmp1!=-1: return tmp1 if tmp2!=-1: return tmp2 if tmp3!=-1: return tmp3 if tmp4!=-1: return tmp4 else: for j in range(n): if s[j]=='x': s[j]='o' else: s[j]='x' return check(0,l) # このときは出力が−1でなければ’W'と'S'を入れ替える elif 1<=i<=n-2: if s[i]=='o': if l[i]=='S': l[i+1]=l[i-1] return check(i+1,l) else: if l[i-1]=='W': l[i+1]='S' return check(i+1,l) else: l[i+1]='W' return check(i+1,l) else: if l[i]=='W': l[i+1]=l[i-1] return check(i+1,l) else: if l[i-1]=='S': l[i+1]='W' return check(i+1,l) else: l[i+1]='S' return check(i+1,l) else: if s[i]=='o': if l[i]=='S': if l[i-1]==l[0]: return l else: return -1 else: if l[i-1]!=l[0]: return l else: return -1 else: if l[i]=='S': if l[i-1]!=l[0]: return l else: return -1 else: if l[i-1]==l[0]: if l[0]=='W' and l[i]==l[1]: return -1 else: return l else: return -1 ans=check(0,l) if ans==-1: print(-1) else: if flag: print(''.join(ans)) else: for i in range(n): if ans[i]=='S': ans[i]='W' else: ans[i]='S' print(''.join(ans))
s760227458
p03798
u863442865
1583687624
Python
Python (3.4.3)
py
Runtime Error
88
4340
1249
#始めの2匹が決まるとあとは自動的に決まるので矛盾していないかどうか判定 def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations #from itertools import accumulate, product from bisect import bisect_left,bisect_right from math import floor, ceil #from operator import itemgetter #mod = 1000000007 N = int(input()) s = list(input()) s += s[0] def check(p): for i in range(1, N): if s[i]=='o' and p[i]=='S': p += p[i-1] elif s[i]=='o' and p[i]=='W': if p[i-1]=='S': p += 'W' else: p += 'S' elif s[i]=='x' and p[i]=='S': if p[i-1]=='S': p += 'W' else: p += 'S' else: p += p[i-1] if p[0]==p[N] and p[1]==p[N+1]: print(p[:-2]) exit() for i in ['SS', 'SW', 'WS', 'WW']: check(i) print(-1) if __name__ == '__main__': main()
s848938323
p03798
u368796742
1582256755
Python
Python (3.4.3)
py
Runtime Error
18
3064
1009
n = int(input()) l = list(input()) check = [[1,1],[1,-1],[-1,1],[-1,-1]] for j,k in check: ans = [0]*n ans[0] = j ans[1] = k for i in range(1,n): if ans[i] == 1: if l[i] == "o": ans[(i+1)%n] = ans[i-1] else: ans[(i+1)%n] = -ans[i-1] else: if l[i] == "o": ans[(i+1)%n] = -ans[i-1] else: ans[(i+1)%n] = ans[i-1] if j == ans[0]: if l[0]=="o": if k == ans[-1]: for i in ans: if i == 1: print("S",end="") else: print("W",end="") exit() else: if k == -ans[-1]: for i in ans: if i == 1: print("S",end="") else: print("W",end="") exit() print(-1)
s389412297
p03798
u557494880
1580004180
Python
Python (3.4.3)
py
Runtime Error
18
3492
3564
N = int(input()) S = input() def f(n): if n == 'S': return 'W' if n == 'W': return 'S' A = ['S','S'] fa = 1 B = ['S','W'] fb = 1 C = [W,W] fc = 1 D = [W,S] fd = 1 s = fa + fb + fc + fd for i in range(1,N-1): x = S[i] if x == 'o': if A[i] == 'S': A.append(A[i-1]) else: A.append(f(A[i-1])) if B[i] == 'S': B.append(B[i-1]) else: B.append(f(B[i-1])) if C[i] == 'S': C.append(C[i-1]) else: C.append(f(C[i-1])) if D[i] == 'S': D.append(D[i-1]) else: D.append(f(D[i-1])) else: if A[i] == 'S': A.append(f(A[i-1])) else: A.append(A[i-1]) if B[i] == 'S': B.append(f(B[i-1])) else: B.append(B[i-1]) if C[i] == 'S': C.append(f(C[i-1])) else: C.append(C[i-1]) if D[i] == 'S': D.append(f(D[i-1])) else: D.append(D[i-1]) if S[0] == 'o': if A[0] == 'S': if A[1] != A[-1]: fa = 0 else: if A[1] == A[-1]: fa = 0 else: if A[0] == 'S': if A[1] == A[-1]: fa = 0 else: if A[1] != A[-1]: fa = 0 if S[-1] == 'o': if A[-1] == 'S': if A[-2] != A[0]: fa = 0 else: if A[-2] == A[0]: fa = 0 else: if A[-1] == 'S': if A[-2] == A[0]: fa = 0 else: if A[-2] != A[0]: fa = 0 if fa == 1: x = A[0] for i in range(1,N): x += A[i] print(x) quit() if S[0] == 'o': if A[0] == 'S': if A[1] != A[-1]: fa = 0 else: if A[1] == A[-1]: fa = 0 else: if B[0] == 'S': if B[1] == B[-1]: fb = 0 else: if B[1] != B[-1]: fb = 0 if S[-1] == 'o': if B[-1] == 'S': if B[-2] != B[0]: fb = 0 else: if B[-2] == B[0]: fb = 0 else: if B[-1] == 'S': if B[-2] == B[0]: fb = 0 else: if B[-2] != B[0]: fb = 0 if fb == 1: x = B[0] for i in range(1,N): x += B[i] print(x) quit() if S[0] == 'o': if C[0] == 'S': if C[1] != C[-1]: fc = 0 else: if C[1] == C[-1]: fc = 0 else: if C[0] == 'S': if C[1] == C[-1]: fc = 0 else: if C[1] != C[-1]: fc = 0 if S[-1] == 'o': if C[-1] == 'S': if C[-2] != C[0]: fa = 0 else: if A[-2] == A[0]: fc = 0 else: if C[-1] == 'S': if C[-2] == C[0]: fc = 0 else: if C[-2] != C[0]: fc = 0 if fc == 1: x = C[0] for i in range(1,N): x += C[i] print(x) quit() if S[0] == 'o': if D[0] == 'S': if D[1] != D[-1]: fd = 0 else: if D[1] == D[-1]: fd = 0 else: if D[0] == 'S': if D[1] == D[-1]: fd = 0 else: if D[1] != D[-1]: fd = 0 if S[-1] == 'o': if D[-1] == 'S': if D[-2] != D[0]: fd = 0 else: if D[-2] == D[0]: fd = 0 else: if D[-1] == 'S': if D[-2] == D[0]: fd = 0 else: if D[-2] != D[0]: fd = 0 if fd == 1: x = D[0] for i in range(1,N): x += D[i] print(x) quit() if s == 0: print(-1)
s709071877
p03798
u121921603
1579038521
Python
PyPy3 (2.4.0)
py
Runtime Error
211
44848
792
import sys input = sys.stdin.readline n=int(input()) s=input() def solve(): for i in range(1,n): if (ans[i]=="S" and s[i]=="o") or (ans[i]=="W" and s[i]=="x"): ans[i+1]=ans[i-1] else: if ans[i-1]=="S": ans[i+1]="W" else: ans[i+1]="S" if (ans[0]=="S" and s[0]=="o") or (ans[0]=="W" and s[0]=="x"): sl=ans[1] else: if a[1]=="S": sl="W" else: sl="S" if ans[0]==ans[-1] and sl==ans[n-1]: return True else: return False ans=[0]*(n+1) for i in ["S","W"]: for j in ["S","W"]: ans[0]=i ans[1]=j if solve(): print("".join(ans[:-1])) exit() print(-1)
s815536637
p03798
u989345508
1579034816
Python
Python (3.4.3)
py
Runtime Error
656
3540
1144
n=int(input()) s=input() x=["SS","SW","WS","WW"] def check(i,j): if j==0: l=0 else: l=1 if x[i][l]=="S": if s[l]=="o": if x[i][l-1]=="S": return x[i][l+1]=="S" else: return x[i][l+1]=="W" else: if x[i][-1]=="S": return x[i][l+1]=="W" else: return x[i][l+1]=="S" else: if s[l]=="o": if x[i][-l1]=="S": return x[i][l+1]=="W" else: return x[i][l+1]=="S" else: if x[i][-1]=="S": return x[i][l+1]=="S" else: return x[i][l+1]=="W" a=["S","W"] for i in range(4): for j in range(n-2): if x[i][j+1]=="S": if s[j+1]=="o": x[i]+=a[x[i][j]!="S"] else: x[i]+=a[x[i][j]=="S"] else: if s[j+1]=="o": x[i]+=a[x[i][j]=="S"] else: x[i]+=a[x[i][j]!="S"] if check(i,0) and check(i,1): print(x[i]) break else: print(-1)
s026682590
p03798
u989345508
1579034766
Python
Python (3.4.3)
py
Runtime Error
648
3608
1146
n=int(input()) s=input() x=["SS","SW","WS","WW"] def check(i,j): if j==0: l=0 else: l=1 if x[i][l]=="S": if s[l]=="o": if x[i][l-1]=="S": return x[i][l+1]=="S" else: return x[i][l+1]=="W" else: if x[i][-1]=="S": return x[i][l+1]=="W" else: return x[i][l+1]=="S" else: if s[l]=="o": if x[i][-l1]=="S": return x[i][l+1]=="W" else: return x[i][l+1]=="S" else: if x[i][-1]=="S": return x[i][l+1]=="S" else: return x[i][l+1]=="W" a=["S","W"] for i in range(4): for j in range(n-2): if x[i][j+1]=="S": if s[j+1]=="o": x[i]+=a[x[i][j]!="S"] else: x[i]+=a[x[i][j]=="S"] else: if s[j+1]=="o": x[i]+=a[x[i][j]=="S"] else: x[i]+=a[x[i][j]!="S"] if check(i,0) and check1(i,-1): print(x[i]) break else: print(-1)
s076835204
p03798
u314089899
1577330946
Python
Python (3.4.3)
py
Runtime Error
104
9212
1553
#55d from functools import lru_cache N = int(input()) s = list(input()) #深さ優先探索 def dfs(ans_list): if len(ans_list) == N: if ((is_contradiction(ans_list[-2],ans_list[-1],ans_list[0],s[-1]) == 0) and (is_contradiction(ans_list[-1],ans_list[0],ans_list[1],s[0]) == 0)): return ans_list else: return [] else: #末尾にSとWを追加し、矛盾していないかを調べる #矛盾していなければ深堀する if is_contradiction(ans_list[-2],ans_list[-1],"S",s[len(ans_list)-1]) == 0: ans_S = dfs(ans_list + ["S"]) else: ans_S = [] if is_contradiction(ans_list[-2],ans_list[-1],"W",s[len(ans_list)-1]) == 0: ans_W = dfs(ans_list + ["W"]) else: ans_W = [] if len(ans_S) >= len(ans_W): return ans_S else: return ans_W #矛盾しているかを検査 @lru_cache(maxsize=1000) def is_contradiction(a,b,c,o_or_x): #print(a,b,c,o_or_x,end="") if ((b == "S" and o_or_x == "o" and a == c) or (b == "S" and o_or_x == "x" and a != c) or (b == "W" and o_or_x == "o" and a != c) or (b == "W" and o_or_x == "x" and a == c)): #print(" OK") return 0 else: #print(" NG") return 1 for first_two_list in [["S","S"],["S","W"],["W","S"],["W","W"]]: ans = dfs(first_two_list) if len(ans) == N: print(''.join(map(str,ans))) break else: print(-1)
s129561767
p03798
u768896740
1575141995
Python
Python (3.4.3)
py
Runtime Error
80
4148
2062
n = int(input()) s = input() def print_animal(): for k in animal_list: print(k, end='') exit() def checker(animal): # print(animal_list) global position position += 1 # print(s[position]) if position != n-1: if s[position] == 'o' and animal == 'S' and animal_list[position-1] == 'S': animal_list.append('S') checker('S') elif s[position] == 'o' and animal == 'S' and animal_list[position-1] == 'W': animal_list.append('W') checker('W') elif s[position] == 'o' and animal == 'W' and animal_list[position-1] == 'S': animal_list.append('W') checker('W') elif s[position] == 'o' and animal == 'W' and animal_list[position-1] == 'W': animal_list.append('S') checker('S') elif s[position] == 'x' and animal == 'S' and animal_list[position-1] == 'S': animal_list.append('W') checker('W') elif s[position] == 'x' and animal == 'S' and animal_list[position-1] == 'W': animal_list.append('S') checker('S') elif s[position] == 'x' and animal == 'W' and animal_list[position-1] == 'S': animal_list.append('S') checker('S') elif s[position] == 'x' and animal == 'W' and animal_list[position-1] == 'W': animal_list.append('W') checker('W') else: if s[position] == 'o' and animal == 'S' and animal_list[0] == animal_list[position-1]: print_animal() elif s[position] == 'o' and animal == 'W' and animal_list[0] != animal_list[position-1]: print_animal() elif s[position] == 'x' and animal == 'S' and animal_list[0] != animal_list[position-1]: print_animal() elif s[position] == 'x' and animal == 'W' and animal_list[0] == animal_list[position-1]: print_animal() for i in [['S', 'S'], ['S', 'W'], ['W', 'W'], ['W', 'S']]: animal_list = i position = 0 checker(animal_list[1]) print(-1)
s274367524
p03798
u768896740
1575140865
Python
Python (3.4.3)
py
Runtime Error
82
4152
2011
n = int(input()) s = input() def print_animal(): for k in animal_list: print(k, end='') exit() def checker(animal): global position position += 1 if position != n-1: if s[position] == 'o' and animal == 'S' and animal_list[position-1] == 'S': animal_list.append('S') checker('S') elif s[position] == 'o' and animal == 'S' and animal_list[position-1] == 'W': animal_list.append('W') checker('W') elif s[position] == 'o' and animal == 'W' and animal_list[position-1] == 'S': animal_list.append('W') checker('W') elif s[position] == 'o' and animal == 'W' and animal_list[position-1] == 'W': animal_list.append('S') checker('S') elif s[position] == 'x' and animal == 'S' and animal_list[position-1] == 'S': animal_list.append('W') checker('W') elif s[position] == 'x' and animal == 'S' and animal_list[position-1] == 'W': animal_list.append('S') checker('S') elif s[position] == 'x' and animal == 'W' and animal_list[position-1] == 'S': animal_list.append('W') checker('W') elif s[position] == 'x' and animal == 'W' and animal_list[position-1] == 'W': animal_list.append('W') checker('S') else: if s[position] == 'o' and animal == 'S' and animal_list[0] == animal_list[position-1]: print_animal() elif s[position] == 'o' and animal == 'W' and animal_list[0] != animal_list[position-1]: print_animal() elif s[position] == 'x' and animal == 'S' and animal_list[0] != animal_list[position-1]: print_animal() elif s[position] == 'x' and animal == 'W' and animal_list[0] == animal_list[position-1]: print_animal() for i in [['S', 'S'], ['S', 'W'], ['W', 'W'], ['W', 'S']]: animal_list = i position = 0 checker(animal_list[1]) print(-1)