output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s339479567
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
a,b=input().split() c=a+b a=int.input(a) if(c==a*a): print("Yes") else: print("no")
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s427576267
Accepted
p03456
Input is given from Standard Input in the following format: a b
i = int(input().replace(" ", "")) print("NYoe s"[int(i**0.5) == i**0.5 :: 2])
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s139743303
Accepted
p03456
Input is given from Standard Input in the following format: a b
print("YNeos"[int("".join(input().split())) ** 0.5 % 1 != 0 :: 2])
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s273322473
Wrong Answer
p03456
Input is given from Standard Input in the following format: a b
he = [x * x for x in range(1, 101)] print("YNeos"[int("".join(input().split())) not in he :: 2])
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s274058724
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
k = int(input().replace(" ", "")) ** (1 / 2) print("Yes" if int(k) ** int(k) == k**k else "No")
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s165698448
Wrong Answer
p03456
Input is given from Standard Input in the following format: a b
print("No" if int(input().replace(" ", "")) % 1 else "Yes")
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s344871901
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
i = int(input().replace(' ','')) if i == i ** 0.5 * 2 print("Yes") else: print("No")
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s981985737
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
N = int(''.join(input().split())) sq = False for k in range(1, N): sq |= k*k==N: print('Yes' if sq else 'No')
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s611389512
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
a,b=map(int,input().split()) print("Yes" if (10a+b)**.5==int((10a+b)**.5) else "No")
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s425714086
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
a,b=map(str,input().split()) ab=int(a+b) if (ab**.5).is_integer() = "True": print("Yes") else: print("No")
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s820684028
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
# coding: utf-8 N = input().split(,) N_list=list(N) AA = N_list[0]+N_list[1] while 10000: q = 0 if (q*q)== AA: print("Yes") break elif(q==10000): print("No") break q += 1
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s421410453
Accepted
p03456
Input is given from Standard Input in the following format: a b
a = big = 1 L = [] while big < 100100: big = a * a L.append(big) a += 1 print(" YNeos"[eval(input().replace(" ", "")) in L :: 2])
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s594615546
Accepted
p03456
Input is given from Standard Input in the following format: a b
print(["Yes", "No"][int(input().replace(" ", "")) ** 0.5 % 1 > 0])
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s611539765
Accepted
p03456
Input is given from Standard Input in the following format: a b
tmp = "".join(input().split()) x = int(pow(int(tmp), 0.5)) print(["No", "Yes"][x * x == int(tmp)])
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s286124779
Runtime Error
p03456
Input is given from Standard Input in the following format: a b
print("NYoe s"[int(input().replace(" ", "")) ** (0.5).isinteger() :: 2])
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`. * * *
s906512222
Wrong Answer
p03456
Input is given from Standard Input in the following format: a b
print(sum(616**2 ** ("B" in i) * float(i[:-4]) for i in open(0).readlines()[1:]))
Statement AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
[{"input": "1 21", "output": "Yes\n \n\nAs 121 = 11 \u00d7 11, it is a square number.\n\n* * *"}, {"input": "100 100", "output": "No\n \n\n100100 is not a square number.\n\n* * *"}, {"input": "12 10", "output": "No"}]
Print \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R). * * *
s146579570
Runtime Error
p02617
Input is given from Standard Input in the following format: N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
mod = 10**9 + 7 n, k = map(int, input().split()) arr = list(map(int, input().split())) arr = sorted(arr, reverse=True, key=lambda x: abs(x)) # 絶対値の順にソートする if k == n: # k=nのときはすべてを掛け合わせるほかない ans = 1 for i in range(n): ans *= arr[i] ans %= mod print(ans) else: if ( k % 2 == 1 and max(arr) < 0 ): # 答えが負になる場合は絶対値の小さい順にK個掛け合わせる ans = 1 for i in range(k): ans *= arr[n - 1 - i] ans %= mod print(ans) else: ans = 1 cnt = 0 for i in range(k): # 絶対値の大きい順にK個掛け合わせる if arr[i] < 0: # 負数を掛けた回数を数えておく cnt += 1 ans *= arr[i] ans %= mod if cnt % 2 == 0: # 負数を偶数回掛けていれば答えは非負なのでそのまま出力 print(ans) else: # そうでなければ調整を行う min_plus = -1 min_minus = 1 for i in range( k ): # 絶対値の大きい順にK個を見て最小の非負の数・負の数を探す if arr[i] >= 0: min_plus = arr[i] else: min_minus = arr[i] max_plus = -1 max_minus = 1 for i in range(k, n): # 残るN-K個を見て最大の非負の数・負の数を探す if arr[i] >= 0 and max_plus == -1: max_plus = arr[i] if arr[i] < 0 and max_minus == 1: max_minus = arr[i] if ( min_plus == -1 ): # もし最小の非負の数がなければ、最小の負の数を取り除くしかない arr.remove(min_minus) ans = 1 for i in range(k - 1): ans *= arr[i] ans %= mod ans *= max_plus ans %= mod elif ( min_minus == 1 ): # もし最小の負の数がなければ、最小の非負の数を取り除くしかない arr.remove(min_plus) ans = 1 for i in range(k - 1): ans *= arr[i] ans %= mod ans *= max_minus ans %= mod elif ( min_plus * max_plus >= min_minus * max_minus ): # そうでなければより倍率の大きいほうを選ぶ arr.remove(min_minus) ans = 1 for i in range(k - 1): ans *= arr[i] ans %= mod ans *= max_plus ans %= mod else: arr.remove(min_plus) ans = 1 for i in range(k - 1): ans *= arr[i] ans %= mod ans *= max_minus ans %= mod print(ans)
Statement We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i. For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows: * Let S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S. Compute \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R).
[{"input": "3\n 1 3\n 2 3", "output": "7\n \n\nWe have six possible pairs (L, R) as follows:\n\n * For L = 1, R = 1, S = \\\\{1\\\\} and we have 1 connected component.\n * For L = 1, R = 2, S = \\\\{1, 2\\\\} and we have 2 connected components.\n * For L = 1, R = 3, S = \\\\{1, 2, 3\\\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n * For L = 2, R = 2, S = \\\\{2\\\\} and we have 1 connected component.\n * For L = 2, R = 3, S = \\\\{2, 3\\\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n * For L = 3, R = 3, S = \\\\{3\\\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\n* * *"}, {"input": "2\n 1 2", "output": "3\n \n\n* * *"}, {"input": "10\n 5 3\n 5 7\n 8 9\n 1 9\n 9 10\n 8 4\n 7 4\n 6 10\n 7 2", "output": "113"}]
Print \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R). * * *
s754467738
Runtime Error
p02617
Input is given from Standard Input in the following format: N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
import numpy as np N, K = map(int, input().split()) A = list(map(int, input().split())) mod = int(1e9 + 7) A = np.array(sorted(A, reverse=True, key=lambda x: abs(x))) if sum(np.sign(A)) == -N and K % 2 == 1: A = sorted(A, reverse=True) last_p = 0 last_m = 0 eliminate_m = 0 eliminate_p = 0 add_m = 0 add_p = 0 ans = 1 for i in range(N): if i < K: ans = (ans * A[i]) % mod if A[i] > 0: last_p = i else: last_m = i else: if A[i] > 0 and eliminate_m == 0: eliminate_m = A[last_p] * A[i] add_p = A[i] elif A[i] < 0 and eliminate_p == 0: eliminate_p = A[last_m] * A[i] add_m = A[i] if i == K - 1: if ans > 0: break if eliminate_p > 0 or eliminate_m > 0: if eliminate_m > eliminate_p: ans = (ans * pow(A[last_m], mod - 2)) % mod ans = (ans * add_p) % mod else: ans = (ans * pow(A[last_p], mod - 2)) % mod ans = (ans * add_m) % mod print(ans)
Statement We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i. For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows: * Let S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S. Compute \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R).
[{"input": "3\n 1 3\n 2 3", "output": "7\n \n\nWe have six possible pairs (L, R) as follows:\n\n * For L = 1, R = 1, S = \\\\{1\\\\} and we have 1 connected component.\n * For L = 1, R = 2, S = \\\\{1, 2\\\\} and we have 2 connected components.\n * For L = 1, R = 3, S = \\\\{1, 2, 3\\\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n * For L = 2, R = 2, S = \\\\{2\\\\} and we have 1 connected component.\n * For L = 2, R = 3, S = \\\\{2, 3\\\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n * For L = 3, R = 3, S = \\\\{3\\\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\n* * *"}, {"input": "2\n 1 2", "output": "3\n \n\n* * *"}, {"input": "10\n 5 3\n 5 7\n 8 9\n 1 9\n 9 10\n 8 4\n 7 4\n 6 10\n 7 2", "output": "113"}]
Print \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R). * * *
s642399549
Runtime Error
p02617
Input is given from Standard Input in the following format: N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
N, K = map(int, input().split()) A = list(map(int, input().split())) MOD = 10**9 + 7 A = sorted(A) if N == K: ans0 = 1 for a in A[0:N]: ans0 *= a ans0 %= MOD print(ans0) exit() if K % 2 == 1 and A[-1] < 0: ans0 = 1 for a in A[N - K : N]: ans0 *= a ans0 %= MOD print(ans0) exit() ansA = 1 for a in A[0:K]: ansA *= a ansA %= MOD A = sorted(A, reverse=True) ansB = 1 for a in A[0:K]: ansB *= a ansB %= MOD A = sorted(A, key=lambda x: abs(x), reverse=True) ansC = 1 for a in A[0:K]: ansC *= a ansC %= MOD ansD = 1 for a in A[0 : K - 1]: ansD *= a ansD %= MOD B = sorted(A[K - 1 : N]) if ansD > 0: ansD *= B[-1] elif ansD < 0: ansD *= B[0] if 0 in B: ansE = 0 else: ansE = ansD # print(ansA, ansB, ansC) print(max(ansA, ansB, ansC, ansD, ansE) % MOD)
Statement We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i. For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows: * Let S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S. Compute \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R).
[{"input": "3\n 1 3\n 2 3", "output": "7\n \n\nWe have six possible pairs (L, R) as follows:\n\n * For L = 1, R = 1, S = \\\\{1\\\\} and we have 1 connected component.\n * For L = 1, R = 2, S = \\\\{1, 2\\\\} and we have 2 connected components.\n * For L = 1, R = 3, S = \\\\{1, 2, 3\\\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n * For L = 2, R = 2, S = \\\\{2\\\\} and we have 1 connected component.\n * For L = 2, R = 3, S = \\\\{2, 3\\\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n * For L = 3, R = 3, S = \\\\{3\\\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\n* * *"}, {"input": "2\n 1 2", "output": "3\n \n\n* * *"}, {"input": "10\n 5 3\n 5 7\n 8 9\n 1 9\n 9 10\n 8 4\n 7 4\n 6 10\n 7 2", "output": "113"}]
Print \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R). * * *
s687507989
Runtime Error
p02617
Input is given from Standard Input in the following format: N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
N, K = map(int, input().split()) mod = 10**9 + 7 plus = [] minus = [] zlen = 0 for i in map(int, input().split()): if i >= 0: plus.append(i) elif i < 0: minus.append(i) else: zlen += 1 plen = len(plus) mlen = len(minus) if K > plen + mlen: print(0) import sys sys.exit() plus.sort(reverse=True) minus.sort() pp = [1] mp = [1] for p in plus: pp.append((pp[-1] * p)) for m in minus: mp.append((mp[-1] * (-m))) ppm = [1] mpm = [1] for p in plus[::-1]: ppm.append((ppm[-1] * p)) for m in minus[::-1]: mpm.append((mpm[-1] * (-m))) ans = -float("inf") ans_m = float("inf") # kこマイナスから選ぶ for k in range(K + 1): if mlen < k: continue if plen < K - k: continue # 最大を目指す if k % 2 == 0: tmp = mp[k] * pp[K - k] ans = max(ans, tmp) # 絶対値最小を目指す else: tmp = mpm[k] * ppm[K - k] ans = min(ans, tmp) if ans == -float("inf"): ans = -ans_m if ans < 0 and zlen > 0: print(0) import sys sys.exit() print(ans % mod)
Statement We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i. For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows: * Let S be the set of the vertices numbered L through R. f(L, R) represents the number of connected components in the subgraph formed only from the vertex set S and the edges whose endpoints both belong to S. Compute \sum_{L=1}^{N} \sum_{R=L}^{N} f(L, R).
[{"input": "3\n 1 3\n 2 3", "output": "7\n \n\nWe have six possible pairs (L, R) as follows:\n\n * For L = 1, R = 1, S = \\\\{1\\\\} and we have 1 connected component.\n * For L = 1, R = 2, S = \\\\{1, 2\\\\} and we have 2 connected components.\n * For L = 1, R = 3, S = \\\\{1, 2, 3\\\\} and we have 1 connected component, since S contains both endpoints of each of the edges 1, 2.\n * For L = 2, R = 2, S = \\\\{2\\\\} and we have 1 connected component.\n * For L = 2, R = 3, S = \\\\{2, 3\\\\} and we have 1 connected component, since S contains both endpoints of Edge 2.\n * For L = 3, R = 3, S = \\\\{3\\\\} and we have 1 connected component.\n\nThe sum of these is 7.\n\n* * *"}, {"input": "2\n 1 2", "output": "3\n \n\n* * *"}, {"input": "10\n 5 3\n 5 7\n 8 9\n 1 9\n 9 10\n 8 4\n 7 4\n 6 10\n 7 2", "output": "113"}]
Print the minimum number of people who have to change their directions. * * *
s329441409
Wrong Answer
p03339
Input is given from Standard Input in the following format: N S
N = int(input()) S = input() s1 = S[1:] b = [] b.append(s1.count("E")) j = 1 while j < N: b.append(0) b[j] = b[j - 1] if S[j] == "E": b[j] += -1 if S[j - 1] == "W": b[j] += 1 j += 1 print(b)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s489689242
Accepted
p03339
Input is given from Standard Input in the following format: N S
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on 2019/3/16 Solved on 2019/3/ @author: shinjisu """ # ABC 098 C Attention # import math # import numpy as np def getInt(): return int(input()) def getIntList(): return [int(x) for x in input().split()] # def getIntList(): return np.array(input().split(), dtype=np.longlong) def zeros(n): return [0] * n # def zeros(n): return np.zeros(n, dtype=np.longlong) def getIntLines(n): return [int(input()) for i in range(n)] """ def getIntLines(n): data = zeros(n) for i in range(n): data[i] = getInt() return data """ def zeros2(n, m): return [zeros(m)] * n # obsoleted zeros((n, m))で代替 def getIntMat(n, m): # n行に渡って、1行にm個の整数 # mat = zeros((n, m)) mat = zeros2(n, m) for i in range(n): mat[i] = getIntList() return mat ALPHABET = [chr(i + ord("a")) for i in range(26)] DIGIT = [chr(i + ord("0")) for i in range(10)] N1097 = 10**9 + 7 INF = 10**18 class Debug: def __init__(self): self.debug = True def off(self): self.debug = False def dmp(self, x, cmt=""): if self.debug: if cmt != "": print(cmt, ": ", end="") print(x) return x def prob(): d = Debug() d.off() N = getInt() d.dmp((N)) A = input() d.dmp(A) west, east = 0, 0 for i in range(N): if A[i] == "W": west += 1 else: east += 1 minTurn = east turn = east for i in range(N): if A[i] == "W": pass else: turn -= 1 d.dmp(turn, "turn") minTurn = min(minTurn, turn) # 向きを元に戻して、立場を変える if A[i] == "W": turn += 1 else: turn += 1 - 1 d.dmp(minTurn, "minTurn") return minTurn ans = prob() if ans is None: pass elif type(ans) == tuple and ans[0] == 1: # 1,ans for elm in ans[1]: print(elm) else: print(ans)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s415119586
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
n = int(input()) s = input() l = [0]*n for i in range(n): l[i] = s[0:i].count('W') + s[i+1:]count('E') print(min(l))
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s910403762
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
=int(input()) a=str(input()) b=N for i in range(N): L=a[:i-1] R=a[i-1:] n=L.count('W')+R.count('E') if b>n: b=n else: b+=0 print(b)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s418409525
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
n = int(input()) s = input() ans = s[1:].count("E") a = ans for i in range(n-1): if s[i] == "W" a += 1 if s[i+1] == "E" a -= 1 if a < ans: ans = a print(ans)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s731434203
Accepted
p03339
Input is given from Standard Input in the following format: N S
############################################################################### from sys import stdout from bisect import bisect_left as binl from copy import copy, deepcopy from collections import defaultdict mod = 1 def intin(): input_tuple = input().split() if len(input_tuple) <= 1: return int(input_tuple[0]) return tuple(map(int, input_tuple)) def intina(): return [int(i) for i in input().split()] def intinl(count): return [intin() for _ in range(count)] def modadd(x, y): global mod return (x + y) % mod def modmlt(x, y): global mod return (x * y) % mod def lcm(x, y): while y != 0: z = x % y x = y y = z return x def combination(x, y): assert x >= y if y > x // 2: y = x - y ret = 1 for i in range(0, y): j = x - i i = i + 1 ret = ret * j ret = ret // i return ret def get_divisors(x): retlist = [] for i in range(1, int(x**0.5) + 3): if x % i == 0: retlist.append(i) retlist.append(x // i) return retlist def get_factors(x): retlist = [] for i in range(2, int(x**0.5) + 3): while x % i == 0: retlist.append(i) x = x // i retlist.append(x) return retlist def make_linklist(xylist): linklist = {} for a, b in xylist: linklist.setdefault(a, []) linklist.setdefault(b, []) linklist[a].append(b) linklist[b].append(a) return linklist def calc_longest_distance(linklist, v=1): distance_list = {} distance_count = 0 distance = 0 vlist_previous = [] vlist = [v] nodecount = len(linklist) while distance_count < nodecount: vlist_next = [] for v in vlist: distance_list[v] = distance distance_count += 1 vlist_next.extend(linklist[v]) distance += 1 vlist_to_del = vlist_previous vlist_previous = vlist vlist = list(set(vlist_next) - set(vlist_to_del)) max_distance = -1 max_v = None for v, distance in distance_list.items(): if distance > max_distance: max_distance = distance max_v = v return (max_distance, max_v) def calc_tree_diameter(linklist, v=1): _, u = calc_longest_distance(linklist, v) distance, _ = calc_longest_distance(linklist, u) return distance ############################################################################### def main(): n = intin() s = input() now = 0 for c in s[1:]: if c == "E": now += 1 ans = now for i in range(n - 1): if s[i] == "W": now += 1 if s[i + 1] == "E": now -= 1 ans = min(now, ans) print(ans) if __name__ == "__main__": main()
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s021082054
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
[carbon:~/src/github.com/hilolih/atcoder:148](! master )% cat ABC098/c.py # -*- coding: utf-8 -*- import sys # ---------------------------------------------------------------- # Use Solve Function def solve(lines): N = int(lines.pop(0)) S = lines.pop(0) RS = S[::-1] S = 'x' + S RS = 'x' + RS slist = [] rslist = [] ss = 0 rss = 0 for i in range(N): if S[i] == 'W': ss += 1 if RS[i] == 'E': rss += 1 slist.append(ss) rslist.insert(0,rss) #print(S) #print(RS) #print(list( zip(slist, rslist))) print(min([s + r for s, r in zip(slist, rslist)])) # # main # # 2. use stdin lines = [x.strip() for x in sys.stdin.readlines()] # # solve !! # solve(lines)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s372854247
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
N = int(input()) str = input() str_list=list(str) pre_list=[] length_list=[] answer_list=[] answer_first=0 answer_second=0 for i in range (N-1): if str_list[i] != str_list[i+1]: pre_list.append(i) if pre_list == []: print("0") sys.exit() lenlen=len(pre_list) for i in range (lenlen-1): length_list.append(pre_list[i+1]-pre_list[i]) if lenlen=1: for i in range (N): if str_list[i] == "E": seki = -1 else: seki = 1 point = (i-pre_list[0])*seki if point<0: answer_first = answer_first+1 print(answer_first) sys.exit() basyo = length_list.index(max(length_list)) basyo2_kouho1 = pre_list[basyo] basyo2_kouho2 = pre_list[basyo+1] for i in range (N): if str_list[i] == "E": seki = -1 else: seki = 1 point = (i-basyo2_kouho1)*seki if point<0: answer_first = answer_first+1 for i in range (N): if str_list[i] == "E": seki = -1 else: seki = 1 point = (i-basyo2_kouho2)*seki if point<0: answer_second = answer_second+1 if answer_first>=answer_second: print(answer_second) else: print(answer_first)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s633776117
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
# -*- coding: utf-8 -*- import os import sys def main(): list_length = int(input()) result = list_length global west_all = data.count("W") data = list(input()) for i in range(list_length): c = l_count(i, data) if c is None: continue elif result > c: result = c print(result) def l_count(i, data): if i > 1 and data[i - 1] != "E": return None west = data[:i].count("W") east = len(data[i:]) - (west_all - west) return west + east if __name__ == '__main__': main()
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s027015188
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(10000) # Debug output def chkprint(*args): names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()} print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] # -------------------------------------------- dp = None S = None def main(): global S N = int(input()) S = input() if N == 2: if S == "WE": print(1) else: print(0) sys.exit() E, W = [], [] e, w = 0, 0 for s in S: if s == "E": e += 1 else: w += 1 E.append(e) W.append(w) ans = min(ans, E[-1] - E[0 + 1]) for leader in range(1, N): elif leader == N - 1: ans = min(ans, W[leader - 1]) else: ans = min(ans, W[leader - 1] + E[-1] - E[leader + 1]) print(ans) main()
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s873023918
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
N=int(input()) s=input() #毎ステップ毎にカウントする処理→TLE # ans=10**6 # for i in range(1,N): # ans=min(ans,s[:i-1].count("W")+s[i+1:].count("E")) # print(ans) ans=[] ans.append(s[1:].count("E")) tmp=ans[0] for i in range(1:N): if s[i]=="E": tmp-=1 if s[i-1]=="W": tmp+=1 ans.append(tmp) print(min(ans))
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s232487610
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
//https://qiita.com/minemine0505/items/9aeae0f651f19f2ac1e2 N = int(input()) S = input() min = S[1:N].count("E") #最小値を保存しておく now = S[1:N].count("E") #i-1 を見ているときのそっぽ向いてる子の数 for i in range (1,N): if S[i-1] == "E" and S[i] == "E": now -= 1 if S[i-1] == "W" and S[i] == "W": now += 1 if now < min: min = now print(min)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s255453082
Runtime Error
p03339
Input is given from Standard Input in the following format: N S
n = int(input()) s = input() str = s[1:] a = 0 for i in str: if i == "E": a += 1 b = a for i in range(len(n)): if str[i] == "w": if str[i+1] == "E": continue else: a += 1 else: if str[i+1] == "E" a -= 1 if b > a: a = b else: continue print(b)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s898460772
Wrong Answer
p03339
Input is given from Standard Input in the following format: N S
def 解(): iN = int(input()) sS = input().rstrip() aE = [0] * iN # 東向かされる人 aW = [0] * iN # 西向かされる人 iMinCost = iN for i in range(1, iN): if sS[i - 1] == "W": aE[i] = aE[i - 1] + 1 else: aE[i] = aE[i - 1] for i in range(iN - 2, -1, -1): if sS[i + 1] == "E": aW[i] = aW[i + 1] + 1 else: aW[i] = aW[i + 1] if aW[i] + aE[i] < iMinCost: iMinCost = aW[i] + aE[i] print(iMinCost) 解()
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s407697135
Accepted
p03339
Input is given from Standard Input in the following format: N S
num = input() # direction = input() ar_direction = list(input()) res = [] west = False last_val = len([d for d in ar_direction[1:] if d == "E"]) for i, d in enumerate(ar_direction): current_res = last_val if west: current_res += 1 west = d == "W" if not i == 0 and not west: current_res -= 1 res.append(current_res) last_val = current_res print(min(res))
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s217301937
Accepted
p03339
Input is given from Standard Input in the following format: N S
# coding:utf-8 import sys import math import time # import numpy as np import collections from collections import deque import queue import copy # 最大公約数 def gcd(m, n): x = max(m, n) y = min(m, n) if x % y == 0: return y else: while x % y != 0: z = x % y x = y y = z else: return z # 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す def bfs(SS, x, y, H, W): # 入力(座標系(迷路), x, y, xの端, yの端) x_next = [0, 0, -1, 1] y_next = [1, -1, 0, 0] tempx = x tempy = y mlength = 0 q = deque() xytuple = (x, y, 0) q.append(xytuple) while q: xytuple = q.popleft() SS[xytuple[0]][xytuple[1]] = "x" # 探索した場所は探索できないようにする for i in range(4): # このforで上下左右を調べてる tempx = xytuple[0] + x_next[i] tempy = xytuple[1] + y_next[i] # print(tempx, tempy, xytuple[2]) # print(S) if ( 0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "." ): temptuple = (tempx, tempy, xytuple[2] + 1) SS[temptuple[0]][ temptuple[1] ] = "x" # 探索した場所は探索できないようにする mlength = max(mlength, xytuple[2] + 1) q.append(temptuple) # print(q) return mlength # 素因数分解 def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a # 重複を検出 def has_duplicates(seq): return len(seq) != len(set(seq)) # X = str(input()).split() # a = [int(x) for x in input().split()] N = int(input()) S = str(input()) c = S.count("E") if S[0] == "E": c -= 1 ans = 0 temp = c for i in range(1, N): if S[i - 1] == "E": if S[i] == "E": c -= 1 if c < temp: ans = i temp = c else: if S[i] == "W": c += 1 print(temp)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s823338268
Wrong Answer
p03339
Input is given from Standard Input in the following format: N S
N = int(input()) str_to_int = {"W": 0, "E": 1} input_ = input() row = [str_to_int[input_[n]] for n in range(N)] min_change_count = N + 1 west_side = row[:0] east_side = row[0:] west_side_count = 0 east_side_count = sum(east_side) count = west_side_count + east_side_count if count < min_change_count: min_change_count = count for n in range(1, N): if row[n - 1] == 0: west_side_count += 1 if row[n] == 1: east_side_count -= 1 count = west_side_count + east_side_count if count < min_change_count: min_change_count = count print(min_change_count)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
Print the minimum number of people who have to change their directions. * * *
s681702351
Accepted
p03339
Input is given from Standard Input in the following format: N S
n = int(input()) s = str(input()) left = s[0] ans = 10**6 left = {} left.setdefault("W", 0) left.setdefault("E", 0) right = {} right.setdefault("E", 0) right.setdefault("W", 0) for i in range(n): right[s[i]] += 1 ans = 10**6 for i in range(n): right[s[i]] -= 1 ans = min(ans, left["W"] + right["E"]) # print(left,right) left[s[i]] += 1 print(ans)
Statement There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
[{"input": "5\n WEEWW", "output": "1\n \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n WEWEWEEEWWWE", "output": "4\n \n\n* * *"}, {"input": "8\n WWWWWEEE", "output": "3"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s088688816
Accepted
p03293
Input is given from Standard Input in the following format: S T
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv)) # 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと def read_a_int(): return int(read()) def read_ints(): return list(map(int, read().split())) def read_col(H): """H is number of rows A列、B列が与えられるようなとき ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合""" ret = [] for _ in range(H): ret.append(list(map(int, read().split()))) return tuple(map(list, zip(*ret))) def read_tuple(H): """H is number of rows""" ret = [] for _ in range(H): ret.append(tuple(map(int, read().split()))) return ret def read_matrix(H): """H is number of rows""" ret = [] for _ in range(H): ret.append(list(map(int, read().split()))) return ret # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため MOD = 10**9 + 7 INF = 2**31 # 2147483648 > 10**9 # default import from collections import defaultdict, Counter, deque from operator import itemgetter from itertools import product, permutations, combinations from bisect import bisect_left, bisect_right # , insort_left, insort_right # https://atcoder.jp/contests/abc103/tasks/abc103_b S = input() T = input() S += S print("Yes" if S.count(T) else "No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s372152092
Accepted
p03293
Input is given from Standard Input in the following format: S T
############################################################################### from sys import stdout from bisect import bisect_left as binl from copy import copy, deepcopy from collections import defaultdict mod = 1 def intin(): input_tuple = input().split() if len(input_tuple) <= 1: return int(input_tuple[0]) return tuple(map(int, input_tuple)) def intina(): return [int(i) for i in input().split()] def intinl(count): return [intin() for _ in range(count)] def modadd(x, y): global mod return (x + y) % mod def modmlt(x, y): global mod return (x * y) % mod def lcm(x, y): while y != 0: z = x % y x = y y = z return x def combination(x, y): assert x >= y if y > x // 2: y = x - y ret = 1 for i in range(0, y): j = x - i i = i + 1 ret = ret * j ret = ret // i return ret def get_divisors(x): retlist = [] for i in range(1, int(x**0.5) + 3): if x % i == 0: retlist.append(i) retlist.append(x // i) return retlist def get_factors(x): retlist = [] for i in range(2, int(x**0.5) + 3): while x % i == 0: retlist.append(i) x = x // i retlist.append(x) return retlist def make_linklist(xylist): linklist = {} for a, b in xylist: linklist.setdefault(a, []) linklist.setdefault(b, []) linklist[a].append(b) linklist[b].append(a) return linklist def calc_longest_distance(linklist, v=1): distance_list = {} distance_count = 0 distance = 0 vlist_previous = [] vlist = [v] nodecount = len(linklist) while distance_count < nodecount: vlist_next = [] for v in vlist: distance_list[v] = distance distance_count += 1 vlist_next.extend(linklist[v]) distance += 1 vlist_to_del = vlist_previous vlist_previous = vlist vlist = list(set(vlist_next) - set(vlist_to_del)) max_distance = -1 max_v = None for v, distance in distance_list.items(): if distance > max_distance: max_distance = distance max_v = v return (max_distance, max_v) def calc_tree_diameter(linklist, v=1): _, u = calc_longest_distance(linklist, v) distance, _ = calc_longest_distance(linklist, u) return distance ############################################################################### def main(): s = input() t = input() for i in range(len(s)): if s == t: print("Yes") return s = s[-1] + s[:-1] print("No") if __name__ == "__main__": main()
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s101639082
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
object Main extends App { def func():Boolean = { var s = scala.io.StdIn.readLine() val t = scala.io.StdIn.readLine() for (_ <- 1 to s.length){ s = s.tail + s.head if (s==t) return true } return false } if (func()) println("Yes") else println("No") }
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s307235561
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s, t = [input() for i in range(2)] for _ in range(len(s)): s = s[1:] + s[0] if s = t: print("Yes") break else: print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s322795307
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s = input() t = input() flag = False for i in range(len(s)): if s == t: flag =True s = s[-1] + s[::len(s)-1 if flag: print("Yes") else: print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s292772080
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
def solve(): s = input() t = input() for i in range(len(s)): if t == s[i:] + s[:i]: return True else False if solve(): print("Yes") else: print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s316861478
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s = str(input()) n = str(input()) ans = 0 for i in range(len(s)): s = s[1:] + s[0] if s == n: ans = 1 break- if ans == 1: print("Yes") else: print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s577029779
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
S = input() T = input() leng = len(S) S = sorted(S) T = sorted(T) ans = True for i in range(leng): if(S[i] != T[i]): ans = False if(ans): print("Yes") else: print"No
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s088102483
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s = input() t = input() if all(s[i] == t[-i-1] for i in range(len(s)))): print('Yes') else: print('No')
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s981261090
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
print('Yes' if (sorted(input()) == sorted(input()) else 'No'))
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s682983251
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
import deque from collections s=list(input()) s=deque(s) t=input() fot i in range(len(s)): if ''.join(s)==t: print("Yes") exit() s.append(s.popleft()) print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s456614052
Accepted
p03293
Input is given from Standard Input in the following format: S T
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 11 05:38:56 2019 @author: shinjisu """ # ABC 200点問題 import math def getInt(): return int(input()) def getIntList(): return [int(x) for x in input().split()] def zeros(n): return [0] * n def dmp(x): global debug if debug: print(x) debug = True def getIntLines(n): return [int(input()) for i in range(n)] def getIntMat(n): mat = [] for i in range(n): mat.append(getIntList()) return mat def zeros2(n, m): return [zeros(m)] * n def prob096(): # Maximum Sum X = getIntList() K = getInt() dmp((X, K)) total = sum(X) - max(X) + max(X) * 2**K return total def prob097(): # Exponential X = getInt() dmp(X) if X == 1: return 1 for n in range(X, 0, -1): dmp(n) for b in range(2, int(math.sqrt(X)) + 1): a = n exp = True while a > 1: if a % b != 0: exp = False break a //= b if exp: break if exp: break return n def prob098(): # Cut and Count N = getInt() S = input() dmp((N, S)) maxChCount = 0 for i in range(1, N): before = S[:i] after = S[i:] dmp((before, after)) chCount = 0 for j in range(26): ch = chr(ord("a") + j) if ch in before and ch in after: chCount += 1 maxChCount = max(maxChCount, chCount) return maxChCount def prob099(): # Stone Momument a, b = getIntList() height = 0 for i in range(b - a + 1): height += i height -= b return height def prob103(): # String Rotation S = input() T = input() for i in range(len(S)): S = S[1:] + S[0] dmp(S) if S == T: return "Yes" else: return "No" def prob000(): # return 0 debug = False # True False print(prob103())
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s272256854
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
英小文字からなる文字列S,Tが与えられます。Sを回転させてTに一致させられるか判定してください。 すなわち、以下の操作を任意の回数繰り返してSをTに一致させられるか判定してください。 操作:S=S1S2...S|S|のとき、SをS|S|S1S2...S|S|−1に変更する ここで、|X|は文字列Xの長さを表します。 """ s = input() t = input() # s,tをリストにする s = list(s) t = list(t) # 変数count,judgementに0を代入 count = 0 judgment = 0 # sの長さだけ順番入れ替えを繰り返し while count <= len(s)+1: item = s.pop() s.insert(0,item) if s == t: # s==tになったらjudgmentでカウントアップ judgment += 1 # 回数をカウントアップ count +=1 # 一回もs==tになってなければNo if judgment == 0: print("No") else: print("Yes")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s671193092
Accepted
p03293
Input is given from Standard Input in the following format: S T
# Author: cr4zjh0bp # Created: Wed Mar 11 16:31:16 UTC 2020 import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdin.readline().split())) nfan = lambda y: [nfa() for _ in range(y)] ns = lambda: stdin.readline().rstrip() nsn = lambda y: [ns() for _ in range(y)] ncl = lambda y: [list(ns()) for _ in range(y)] nas = lambda: stdin.readline().split() S = ns() T = ns() N = len(S) flag = False for i in range(N + 1): q = S[:i] p = S[i:] if p + q == T: flag = True print("Yes" if flag else "No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s259129850
Accepted
p03293
Input is given from Standard Input in the following format: S T
S, T = map(str, [input() for i in range(0, 2)]) print("Yes" if str(T + T).find(S) >= 0 else "No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s535747611
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
S = list(input()) T = list(input()) for i in range(len(S)): tmp = S[i:] + [:i] if T == tmp: print('Yes') break print('No')
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s154730977
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
S=input() s=list(S) T=input() t=list(T) for i in range(len(s)): s.insert(0,s[-1]) print(s) s.pop(-1) print(s) if s==t: print('Yes') exit() print('N
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s377431256
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
N = int(input()) print("Yes" if 9 in N else "No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s027353900
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s = input().strip() t = input().strip() print ("Yes" if any(s[i:] + s[:i] == t for i in range(len(s)) else "No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s373997294
Accepted
p03293
Input is given from Standard Input in the following format: S T
s, t = list(input()), list(input()) n = len(s) num = 0 ans_t = [] if s[0] == t[-1] and s[1] == t[0]: ans_t = s[1:] + [s[0]] else: for j in range(n - 1): if s[0] == t[j] and s[1] == t[j + 1]: num = j for i in range(num): ans_t.append(s[n - num + i]) for i in range(n - num): ans_t.append(s[i]) print("Yes" if t == ans_t or s == t else "No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s666037566
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
import numpy as np a_in = input() b_in = input() a = list(a_in) b = list(b_in) an = np.array(a) bn = np.array(b) no =0 for i in an: if ln(bn.where(i)) == 1: pass else: print(No) no = 1 break if no == 0: print(Yes)
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s921074904
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s = list(input()) t = list(input()) for i in range(len(s)): check = True: for j in range(len(s)): if t[j] != s[(i+j)%len(s)]: check = False if check: print("Yes") exit() print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s970041724
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s=[i for i in input()] t=[i for i in input()] a=0 for i in range(len(s)): if s==t: a+=1 s=[s[i] for i in range(-1,len(s)-1)] print("Yes" if a>=1 else "No")s=[i for i in input()] t=[i for i in input()] a=0 for i in range(len(s)): if s==t: a+=1 s=[s[i] for i in range(-1,len(s)-1)] print("Yes" if a>=1 else "No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s404859096
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
import collections deque S=deque(input()) T=deque(input()) for i in range(len(T)): if S==T: print("Yes") exit() t=T.popleft() T.appendleft(t) print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s814096154
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
S = input() T = input() for i in range(len(S)): s = S[len(S)] S'= S[0:-1] if S==T print("Yes") break S = s + S' else: print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s960697301
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s = input() t = input() x = len(s) if s == t: print('Yes') for z in range(x): u[0] = s[x-1] for y in range(x-2): u[0] = s[x-1] u[y+1] = s[y] if t == u; print('Yes') s = u
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s756367278
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
S = input() T = input() for i in range(len(S)): if T==S print("Yes") break S = S[-1]+ S[:-1] else: print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s044802631
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
s = input() t = input() for _ in range(len(s)): if s = t: print('Yes') exit() s = s[-1]+s[:-1] print('No')
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s451066111
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
a=input() b=input() A=a*2 d= b in A if d="True" print("Yes") else: print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
If S equals T after _rotation_ , print `Yes`; if it does not, print `No`. * * *
s397722062
Runtime Error
p03293
Input is given from Standard Input in the following format: S T
A = input() B = input() for i in range(len(A)): if(A == B):   print("Yes")   exit()   A = (A+A[0])[1:] print("No")
Statement You are given string S and T consisting of lowercase English letters. Determine if S equals T after _rotation_. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the length of the string X.
[{"input": "kyoto\n tokyo", "output": "Yes\n \n\n * In the first operation, `kyoto` becomes `okyot`.\n * In the second operation, `okyot` becomes `tokyo`.\n\n* * *"}, {"input": "abc\n arc", "output": "No\n \n\n`abc` does not equal `arc` after any number of operations.\n\n* * *"}, {"input": "aaaaaaaaaaaaaaab\n aaaaaaaaaaaaaaab", "output": "Yes"}]
In the first line, print |s|, the length of s. In the second line, print the elements in s in order, with spaces in between. Any string that satisfies the above conditions will be accepted. * * *
s274304464
Wrong Answer
p03769
Input is given from Standard Input in the following format: N
n = int(input()) factorials = [1, 1] for i in range(2, 40): factorials.append(factorials[-1] * i) patterns = [] for i in range(2, 40): base = (1 << (i - 1)) - 1 patterns.append((base, -i, 0)) if i % 2 == 0: j = i // 2 patterns.append( (base + factorials[i] // factorials[j] // factorials[j], -i - 2, 1) ) patterns.sort(reverse=True) ans = [] c = 1 i = 0 while n: if n >= patterns[i][0]: n -= patterns[i][0] if patterns[i][2] == 0: ans.extend([c] * -patterns[i][1]) c += 1 else: j = (-patterns[i][1] - 2) // 2 ans.extend([c] * j) ans.append(c + 1) ans.extend([c] * j) ans.append(c + 1) c += 2 else: i += 1 print(len(ans)) print(*ans)
Statement We will call a string x _good_ if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `abcabcabc` and `abba` are not good. Eagle and Owl created a puzzle on good strings. Find one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem. * 1 ≤ |s| ≤ 200 * Each character of s is one of the 100 characters represented by the integers 1 through 100. * Among the 2^{|s|} subsequences of s, exactly N are good strings.
[{"input": "7", "output": "4\n 1 1 1 1\n \n\nThere are two good strings that appear as subsequences of s: (1,1) and\n(1,1,1,1). There are six occurrences of (1,1) and one occurrence of (1,1,1,1),\nfor a total of seven.\n\n* * *"}, {"input": "299", "output": "23\n 32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10"}]
In the first line, print |s|, the length of s. In the second line, print the elements in s in order, with spaces in between. Any string that satisfies the above conditions will be accepted. * * *
s970922904
Accepted
p03769
Input is given from Standard Input in the following format: N
def nCr(a, b): tmp = 1 for i in range(a, a - b, -1): tmp *= i for i in range(1, b + 1, 1): tmp //= i return tmp n = int(input()) out = [] co = 1 coo = 0 while n > 0: t = 2 while True: sum1 = 0 for j in range(2, t + 1, 2): sum1 += nCr(t, j) # print(n,sum) if n < sum1: t -= 1 # n-=rco break rco = sum1 t += 1 ad = [co for _ in range(t)] sum1 = rco ma = sum1 # print(ma) for toa in range(1, 4): for tob in range(1, 4): CO = 0 for r in range(1, min(toa, tob) + 1): CO += nCr(toa, r) * nCr(tob, r) for a in range(1, t): sum2 = sum1 + ((2 ** (toa + tob - 1)) - 1) for b in range(1, a + 1): sum2 += nCr(a, b) * nCr(t - a, b) * CO if sum2 > n: continue if ma < sum2: ma = sum2 ad = [co for _ in range(a)] for _ in range(toa): ad.append(100 - coo) for _ in range(t - a): ad.append(co) for _ in range(tob): ad.append(100 - coo) # print(ad,0,ma) for t in ad: out.append(t) # out.append(ad) n -= ma coo += 1 co += 1 print(len(out)) print(*out)
Statement We will call a string x _good_ if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `abcabcabc` and `abba` are not good. Eagle and Owl created a puzzle on good strings. Find one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem. * 1 ≤ |s| ≤ 200 * Each character of s is one of the 100 characters represented by the integers 1 through 100. * Among the 2^{|s|} subsequences of s, exactly N are good strings.
[{"input": "7", "output": "4\n 1 1 1 1\n \n\nThere are two good strings that appear as subsequences of s: (1,1) and\n(1,1,1,1). There are six occurrences of (1,1) and one occurrence of (1,1,1,1),\nfor a total of seven.\n\n* * *"}, {"input": "299", "output": "23\n 32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10"}]
In the first line, print |s|, the length of s. In the second line, print the elements in s in order, with spaces in between. Any string that satisfies the above conditions will be accepted. * * *
s605882678
Accepted
p03769
Input is given from Standard Input in the following format: N
fact = [1] for i in range(1, 101): fact.append(fact[-1] * i) def C(a, b): return fact[a] // (fact[b] * fact[a - b]) def sC(a, b): ret = 0 for i in range(min(b, a - b) + 1): ret += C(b, i) * C(a - b, i) return ret def calc(n, k): if n <= 0: return [] i = 0 while (1 << (i + 1)) - 1 <= n: i += 1 ret = [str(k)] * (i + 1) rem = n - ((1 << i) - 1) kk = k + 1 i += 1 j = i // 2 while j > 0: while True: tmp = sC(i, j) if tmp <= rem: ret.insert(j, str(kk)) ret.append(str(kk)) kk += 1 rem -= tmp else: break j -= 1 return ret + calc(rem, kk) N = int(input()) X = calc(N, 1) print(len(X)) print(" ".join(X))
Statement We will call a string x _good_ if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `abcabcabc` and `abba` are not good. Eagle and Owl created a puzzle on good strings. Find one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem. * 1 ≤ |s| ≤ 200 * Each character of s is one of the 100 characters represented by the integers 1 through 100. * Among the 2^{|s|} subsequences of s, exactly N are good strings.
[{"input": "7", "output": "4\n 1 1 1 1\n \n\nThere are two good strings that appear as subsequences of s: (1,1) and\n(1,1,1,1). There are six occurrences of (1,1) and one occurrence of (1,1,1,1),\nfor a total of seven.\n\n* * *"}, {"input": "299", "output": "23\n 32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10"}]
Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature. * * *
s247645446
Runtime Error
p03786
The input is given from Standard Input in the following format: N A_1 A_2 … A_N
5 1 1 1 1 1
Statement Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively. Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs another creature of size C and color D (C \leq 2 \times A), they will merge into one creature of size A+C and color B. Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other. Snuke has been watching these creatures merge over and over and ultimately become one creature. Find the number of the possible colors of this creature.
[{"input": "3\n 3 1 4", "output": "2\n \n\nThe possible colors of the last remaining creature are colors 1 and 3. For\nexample, when the creature of color 3 absorbs the creature of color 2, then\nthe creature of color 1 absorbs the creature of color 3, the color of the last\nremaining creature will be color 1.\n\n* * *"}, {"input": "5\n 1 1 1 1 1", "output": "5\n \n\nThere may be multiple creatures of the same size.\n\n* * *"}, {"input": "6\n 40 1 30 2 7 20", "output": "4"}]
Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature. * * *
s946531122
Wrong Answer
p03786
The input is given from Standard Input in the following format: N A_1 A_2 … A_N
import sys import heapq import re from itertools import permutations from bisect import bisect_left, bisect_right from collections import Counter, deque from fractions import gcd from math import factorial, sqrt, ceil from functools import lru_cache, reduce INF = 1 << 60 MOD = 1000000007 sys.setrecursionlimit(10**7) # UnionFind class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots()) def is_prime(n): if n == 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True # ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める) # 計算量n^3 (nは頂点の数) def warshall_floyd(d, n): # d[i][j]: iからjへの最短距離 for k in range(n): for i in range(n): for j in range(n): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) return d # ダイクストラ def dijkstra_heap(s, edge, n): # 始点sから各頂点への最短距離 d = [10**20] * n used = [True] * n # True:未確定 d[s] = 0 used[s] = False edgelist = [] for a, b in edge[s]: heapq.heappush(edgelist, a * (10**6) + b) while len(edgelist): minedge = heapq.heappop(edgelist) # まだ使われてない頂点の中から最小の距離のものを探す if not used[minedge % (10**6)]: continue v = minedge % (10**6) d[v] = minedge // (10**6) used[v] = False for e in edge[v]: if used[e[1]]: heapq.heappush(edgelist, (e[0] + d[v]) * (10**6) + e[1]) return d # 素因数分解 def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr # 2数の最小公倍数 def lcm(x, y): return (x * y) // gcd(x, y) # リストの要素の最小公倍数 def lcm_list(numbers): return reduce(lcm, numbers, 1) # リストの要素の最大公約数 def gcd_list(numbers): return reduce(gcd, numbers) # 素数判定 # limit以下の素数を列挙 def eratosthenes(limit): A = [i for i in range(2, limit + 1)] P = [] while True: prime = min(A) if prime > sqrt(limit): break P.append(prime) i = 0 while i < len(A): if A[i] % prime == 0: A.pop(i) continue i += 1 for a in A: P.append(a) return P # 同じものを含む順列 def permutation_with_duplicates(L): if L == []: return [[]] else: ret = [] # set(集合)型で重複を削除、ソート S = sorted(set(L)) for i in S: data = L[:] data.remove(i) for j in permutation_with_duplicates(data): ret.append([i] + j) return ret # ここから書き始める n = int(input()) a = sorted(list(map(int, input().split()))) c = [0 for i in range(n)] for i in range(n): if i == 0: c[i] - a[i] else: c[i] = c[i - 1] + a[i - 1] # print("c =", c) ans = n for i in range(n): if c[i] != 0 and c[i] * 2 < a[i]: ans -= i break print(ans)
Statement Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively. Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs another creature of size C and color D (C \leq 2 \times A), they will merge into one creature of size A+C and color B. Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other. Snuke has been watching these creatures merge over and over and ultimately become one creature. Find the number of the possible colors of this creature.
[{"input": "3\n 3 1 4", "output": "2\n \n\nThe possible colors of the last remaining creature are colors 1 and 3. For\nexample, when the creature of color 3 absorbs the creature of color 2, then\nthe creature of color 1 absorbs the creature of color 3, the color of the last\nremaining creature will be color 1.\n\n* * *"}, {"input": "5\n 1 1 1 1 1", "output": "5\n \n\nThere may be multiple creatures of the same size.\n\n* * *"}, {"input": "6\n 40 1 30 2 7 20", "output": "4"}]
Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature. * * *
s655920472
Runtime Error
p03786
The input is given from Standard Input in the following format: N A_1 A_2 … A_N
n=int(input()) a=sorted(list(map(int,input().split()))) flag=0 ans=1 a_cumulative=[0] for i in range(n): flag+=a[i] a_cumulative.append(flag) a.reverse() a_cumulative.reverse() for j in range(n-1): if a[j]<= a_cumulative[j+1]*2: ans+=1 print(ans)
Statement Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively. Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs another creature of size C and color D (C \leq 2 \times A), they will merge into one creature of size A+C and color B. Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other. Snuke has been watching these creatures merge over and over and ultimately become one creature. Find the number of the possible colors of this creature.
[{"input": "3\n 3 1 4", "output": "2\n \n\nThe possible colors of the last remaining creature are colors 1 and 3. For\nexample, when the creature of color 3 absorbs the creature of color 2, then\nthe creature of color 1 absorbs the creature of color 3, the color of the last\nremaining creature will be color 1.\n\n* * *"}, {"input": "5\n 1 1 1 1 1", "output": "5\n \n\nThere may be multiple creatures of the same size.\n\n* * *"}, {"input": "6\n 40 1 30 2 7 20", "output": "4"}]
Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature. * * *
s162851162
Accepted
p03786
The input is given from Standard Input in the following format: N A_1 A_2 … A_N
N = int(input()) A = sorted([int(_) for _ in input().split()]) summed = [0] * N summed[0] = A[0] for n in range(1, N): summed[n] = summed[n - 1] + A[n] impossible = 0 for n in range(1, N): if summed[n - 1] * 2 < A[n]: impossible = n print(N - impossible)
Statement Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively. Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs another creature of size C and color D (C \leq 2 \times A), they will merge into one creature of size A+C and color B. Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other. Snuke has been watching these creatures merge over and over and ultimately become one creature. Find the number of the possible colors of this creature.
[{"input": "3\n 3 1 4", "output": "2\n \n\nThe possible colors of the last remaining creature are colors 1 and 3. For\nexample, when the creature of color 3 absorbs the creature of color 2, then\nthe creature of color 1 absorbs the creature of color 3, the color of the last\nremaining creature will be color 1.\n\n* * *"}, {"input": "5\n 1 1 1 1 1", "output": "5\n \n\nThere may be multiple creatures of the same size.\n\n* * *"}, {"input": "6\n 40 1 30 2 7 20", "output": "4"}]
Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature. * * *
s075120383
Wrong Answer
p03786
The input is given from Standard Input in the following format: N A_1 A_2 … A_N
# import math # import copy # import sys # import bisect # input = sys.stdin.readline mod = 10**9 + 7 def swap(a, b): c = a a = b b = c return a, b def factorial(x): # 階乗計算 n = 1 for i in range(x): n = (n * (i + 1)) % mod return n def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def lcm(a, b): return (a * b) // gcd(a, b) def div(x): # 約数配列 div = [1] check = 2 while x != 1 and check <= int(x**0.5) + 2: if x % check == 0: div.append(check) while x % check == 0: x = x // check check += 1 if x != 1: div.append(x) return div def div2(x): # 素因数分解配列 div2 = [] check = 2 while x != 1 and check <= int(x**0.5) + 2: while x % check == 0: div2.append(check) x /= check check += 1 if x != 1: div2.append(x) return div2 def main(): # x,y = map(int,input().split()) x=1,y=2 # a = input().split() a=['1','2','3',...,'n'] # a = list(map(int,input().split())) a=[1,2,3,4,5,...,n] # li = input().split('T') FFFTFTTFF => li=['FFF', 'F', '', 'FF'] # 複数行の「1 2 3 4」型の入力を一配列に # x = sorted([list(map(int, input().split())) for _ in range(n)]) # ソート x.sort(key=lambda y:y[1]) # [chr(i) for i in range(97, 97+26)] 英語小文字リスト # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder # ord(c) chr(2) alphabet <=> number n = int(input()) a = list(map(int, input().split())) ans = 1 k = 0 a.sort() for i in range(n - 1): k += a[i] if k * 2 >= a[i + 1]: print(a[i]) ans += 1 else: ans = 1 print(ans) main()
Statement Snuke found N strange creatures. Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively. Every creature can absorb another creature whose size is at most twice the size of itself. When a creature of size A and color B absorbs another creature of size C and color D (C \leq 2 \times A), they will merge into one creature of size A+C and color B. Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other. Snuke has been watching these creatures merge over and over and ultimately become one creature. Find the number of the possible colors of this creature.
[{"input": "3\n 3 1 4", "output": "2\n \n\nThe possible colors of the last remaining creature are colors 1 and 3. For\nexample, when the creature of color 3 absorbs the creature of color 2, then\nthe creature of color 1 absorbs the creature of color 3, the color of the last\nremaining creature will be color 1.\n\n* * *"}, {"input": "5\n 1 1 1 1 1", "output": "5\n \n\nThere may be multiple creatures of the same size.\n\n* * *"}, {"input": "6\n 40 1 30 2 7 20", "output": "4"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s148908399
Accepted
p04043
The input is given from Standard Input in the following format: A B C
f = lambda l: sum(l) == 17 and max(l) == 7 and min(l) == 5 print("YES" if f(list(map(int, input().split()))) else "NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s857082762
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
li = list(map(int, input().split())) if li = [5,5,7] or [5,7,5] or [7,5,5]: print('Yes') else: print('No')
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s098515670
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
#ABC042B N,L=map(int,input().split()) a=[] for i in range(N) a.append(input()) a.sort() print(''.join(a))
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s780921856
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
l = [int(x) for x in input().split()] l = sorted(l) if l.count(5)==2 and l.count(7)==1: print("YES") else: print("NO"
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s042464143
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
a,b,c = map(int, input().split()) if a,b,c == 5,5,7 or a,b,c == 5,7,5 or a,b,c == 7,5,5: print("YES") else: print("NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s134447825
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
#ABC042B N,L=map(int,input().split()) a=[] for i in range(n) a.append(input()) a.sort() print(''.join(a))
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s531294776
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
lst = list(map(int,input().split())) for i in lst: ct = 0 if i == 5: ct += 1 elif i == 7: ct += 1 if ct == 3: return "YES" else: return "NO"
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s839397582
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
A, B, C = int(input()) res = "NO" if A == 5 or A == 7: if B == 5 or B == 7: if C == 5 or C == 7: if A + B + C == 17: res = "YES" print(res)
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s322525755
Accepted
p04043
The input is given from Standard Input in the following format: A B C
from sys import stdin, stdout import bisect import math def st(): return list(stdin.readline().strip()) def inp(): return int(stdin.readline()) def li(): return list(map(int, stdin.readline().split())) def mp(): return map(int, stdin.readline().split()) def pr(n): stdout.write(str(n) + "\n") def soe(limit): l = [1] * (limit + 1) prime = [] for i in range(2, limit + 1): if l[i]: for j in range(i * i, limit + 1, i): l[j] = 0 for i in range(2, limit + 1): if l[i]: prime.append(i) return prime def segsoe(low, high): limit = int(high**0.5) + 1 prime = soe(limit) n = high - low + 1 l = [0] * (n + 1) for i in range(len(prime)): lowlimit = (low // prime[i]) * prime[i] if lowlimit < low: lowlimit += prime[i] if lowlimit == prime[i]: lowlimit += prime[i] for j in range(lowlimit, high + 1, prime[i]): l[j - low] = 1 for i in range(low, high + 1): if not l[i - low]: if i != 1: print(i) def gcd(a, b): while b: a = a % b b, a = a, b return a def power(a, n): r = 1 while n: if n & 1: r = r * a a *= a n = n >> 1 return r def solve(): l = li() l.sort() if l == [5, 5, 7]: pr("YES") else: pr("NO") for _ in range(1): solve()
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s711657154
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
#!/usr/bin/python # -*- coding: UTF-8 -*- import sys def input(): return sys.stdin.readline().strip() def _main(): input() s = sorted(list(input().split())) print("".join(s)) if __name__ == "__main__": _main()
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s557456891
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
x = input().split() fn = 0 sn = 0 for i in range(len(x)): if int(x[i]) == 5: fn += 1 elif int(x[i]) == 7: sn += 1 if fn = 2: if sn = 5: print("YES") else: print("NO") else: print("NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s405860257
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
clause_list = list(map(int, input().split())) for index, clause in enumerate(clause_list): if clause = 5: clause_list.pop(index) break for index, clause in enumerate(clause_list): if clause = 7: clause_list.pop(index) break for index, clause in enumerate(clause_list): if clause = 5: clause_list.pop(index) break print('YES' if len(clause_list) == 0 else 'NO')
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s102653975
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
#!/usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 inf = float('INF') #A def A(): a = LI() a.sort() if a = [5, 5, 7]: print("YES") else: print("NO") return #B def B(): return #C def C(): return #D def D(): return #E def E(): return #F def F(): return #G def G(): return #H def H(): return #Solve if __name__ == '__main__': A()
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s305443073
Wrong Answer
p04043
The input is given from Standard Input in the following format: A B C
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, ) from itertools import ( accumulate, permutations, combinations, combinations_with_replacement, product, groupby, ) from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10**9) INF = float("inf") mod = 10**9 + 7 A = LIST() if all(x in A for x in [5, 7]) and sum(A) == 17: print("Yes") else: print("No")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s757650744
Accepted
p04043
The input is given from Standard Input in the following format: A B C
xs = list(map(int, input().split())) print("YES" if xs.count(5) == 2 and xs.count(7) == 1 else "NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s449627703
Accepted
p04043
The input is given from Standard Input in the following format: A B C
tmp = input().split(" ") print("YES") if tmp.count("5") == 2 and tmp.count("7") == 1 else print("NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s378140517
Accepted
p04043
The input is given from Standard Input in the following format: A B C
print("YES" if sorted(map(int, input().strip().split(" "))) == [5, 5, 7] else "NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s636538587
Accepted
p04043
The input is given from Standard Input in the following format: A B C
a = input().replace("5", "") print("NYOE S"[a.count("7") == 1 :: 2])
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s159819480
Accepted
p04043
The input is given from Standard Input in the following format: A B C
print("YNEOS"["7 7" in input() :: 2])
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s619504026
Accepted
p04043
The input is given from Standard Input in the following format: A B C
S = input() print("YES" if S.count("5") == 2 and S.count("7") == 1 else "NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s147632012
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
A,B,C=map(int,input().sprit()) if sorted[A,B,C]=[5,5,7]: print("YES") else: print("NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s307484788
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
S = int(input()) if S.count(5) == 2 && S.count(7): print("YES") else: print("NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s626841225
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
lst = map(int, input().split()) print("YES" if lst.count(5) == 2 and lst.count(7) == 1 else "NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]
If it is possible to construct a Haiku by using each of the phrases once, print `YES` (case-sensitive). Otherwise, print `NO`. * * *
s941333719
Runtime Error
p04043
The input is given from Standard Input in the following format: A B C
x,y,z = map(int,input().split()) if(x=5 and y=7 and z=5): print("YES") else: print("NO")
Statement Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
[{"input": "5 5 7", "output": "YES\n \n\nUsing three phrases of length 5, 5 and 7, it is possible to construct a Haiku.\n\n* * *"}, {"input": "7 7 5", "output": "NO"}]