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
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s104606372
Accepted
p02664
Input is given from Standard Input in the following format: T
print("".join(["D" if x == "?" else x for x in input()]))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s139057850
Accepted
p02664
Input is given from Standard Input in the following format: T
print("".join(["D" if c == "?" else c for c in input()]))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s202728834
Accepted
p02664
Input is given from Standard Input in the following format: T
import sys # 実行環境(0:vscode, 1:atcoder) MODE = 1 # 入力の次元 DIMENSION = 0 # int型に変換 INT_TYPE = 0 if not (MODE): with open("input.txt", "r") as f: s = f.read() else: s = sys.stdin.read() if DIMENSION == 0: if INT_TYPE == 1: s = int(s) elif DIMENSION == 1: if INT_TYPE == 0: s = s.split() elif INT_TYPE == 1: s = [int(x) for x in s.split()] elif DIMENSION == 2: if INT_TYPE == 0: s = [x.split() for x in s.splitlines()] elif INT_TYPE == 1: s = [[int(y) for y in x.split()] for x in s.splitlines()] ss = [None for _ in range(len(s))] for i, t in enumerate(s): if t == "?": ss[i] = "D" else: ss[i] = t print("".join(ss))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s081878031
Accepted
p02664
Input is given from Standard Input in the following format: T
t=input() t=t.replace("?","D") cd=t.count("D") cdp=t.count("PD") # print(cd+cdp) print(t)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s538431525
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
s = input().replace("?", "D") print(s.count("PD") + s.count("D"))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s720098643
Accepted
p02664
Input is given from Standard Input in the following format: T
pd = input() after_pd = "" for i in pd: if i == "?": after_pd += "D" else: after_pd += i count = 0 # if after_pd[0]=="D": # count +=1 # else: # flg=1 # for i in range(1,len(after_pd)): # if after_pd[i-1]=="P" and after_pd[i]=="D": # count +=1 # if after_pd[i]=="D": # count +=1 # print(count) print(after_pd)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s330486388
Runtime Error
p02664
Input is given from Standard Input in the following format: T
l1 = list(input()) k = l1.count("?") for i in range(l1): if l1[i] == "?": l1[i] = "D" s = l1.join("") print(s)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s262271019
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
strs = list(input()) for i in range(len(strs)): if strs[i] == "?": strs[i] = "D" print(strs)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s187842377
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
T = input().replace("?", "D") print(T.count("D") + T.count("PD"))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s240114563
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
s=input() s.replace('?', 'D') print(s)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s987469330
Accepted
p02664
Input is given from Standard Input in the following format: T
from collections import deque T = input().rstrip() d = deque() d.extend(list(T)) answer = deque() window = deque(maxlen=3) for a in d: if a == "?": answer.append("D") else: answer.append(a) print("".join(answer))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s929334191
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
pd = list(map(str, input())) # print(pd) for i in range(len(pd)): if pd[i] == "?": if i == len(pd) - 1: pd[i] = "D" else: if pd[i + 1] == "D": pd[i] = "P" else: pd[i] = "D" print("".join(pd))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s594925970
Accepted
p02664
Input is given from Standard Input in the following format: T
li = list(input()) lis = li.copy() count1 = 0 count2 = 0 for i in range(0, len(li)): if li[i] == "P": try: if li[i + 1] != "P": count1 += 1 li[i + 1] = "D" except IndexError: continue elif li[i] == "?": li[i] = "P" else: continue for i in range(0, len(lis)): if lis[i] == "P": try: if lis[i + 1] != "P": count2 += 1 lis[i + 1] = "D" except IndexError: continue elif lis[i] == "?": lis[i] = "D" else: continue c = li.count("D") d = lis.count("D") a = c + count1 b = d + count2 if a >= b: for i in li: print(i, end="") else: for i in lis: print(i, end="")
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s210425402
Accepted
p02664
Input is given from Standard Input in the following format: T
# B T = str(input()) try: for i in range(T.count("?")): index = T.index("?") if T[index - 1] == "P": T = T.replace("?", "D", 1) elif T[index + 1] == "D": T = T.replace("?", "P", 1) elif T[index + 1] == "?": T = T.replace("?", "P", 1) else: T = T.replace("?", "D", 1) print(T) except: print(T.replace("?", "D"))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s936491294
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
T = input() ans = "" now = 0 # now は現在の文字数 for i in range(len(T)): if now == len(T): break else: if T[now] == "D": ans += "D" now += 1 elif T[now] == "P": ans += "P" now += 1 else: # つまり T[now] == "?" # 先頭の場合 if now == 0: if now + 1 == len(T): ans += "D" now += 1 # 末尾の場合 elif now == len(T) - 1: ans += "D" now += 1 else: if now + 1 == len(T): # 次の文字が末尾の場合 if ans[now - 1] == "P": ans += "D" else: ans += "P" now += 1 else: # 次の文字が"P" if T[now + 1] == "P": ans += "DP" now += 2 # 次の文字が"D" elif T[now + 1] == "D": ans += "PD" now += 2 # 次の文字が"?" if T[now - 1] == "D": ans += "P" now += 1 else: ans += "D" now += 1 for j in range(len(T)): if now == len(T): break if T[now] == "?": if ans[now - 1] == "D": ans += "P" now += 1 elif ans[now - 1] == "P": ans += "D" now += 1 else: ans += T[now] now += 1 break print(ans)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s382839475
Runtime Error
p02664
Input is given from Standard Input in the following format: T
T = input() t = T.count("?") num = [] for i in range(0, t + 1): st = T.replace("?", "D", i) for n in range(0, t + 1): ste = st.replace("?", "P", n) for q in range(0, t + 1): stes = ste.replace("?", "D", q) num.append(stes) print(num) s = stes.count("DD") f = stes.count("PD") ans = s + f
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s033486941
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
def main(): import itertools, copy, sys input = sys.stdin.readline T = list(input()) TC = T N = [i for i, x in enumerate(T) if x == "?"] B = list(itertools.product(["P", "D"], repeat=len(N))) point = [0] * len(B) strs = [""] * len(B) TC_count = TC.count for b, i in zip(B, range(len(B))): TC = copy.deepcopy(T) for n, j in zip(N, range(len(N))): TC[n] = b[j] TC = "".join(TC) strs[i] = TC point[i] = TC_count("PD") + TC_count("D") maxin = max(point) print(strs[point.index(maxin)]) main() if __name__ == "__main__": main()
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s141471930
Runtime Error
p02664
Input is given from Standard Input in the following format: T
T = input() lis = list(T) n = lis.count("?") temp = [i for i, x in enumerate(lis) if x == "?"] t = 0 op_cnt = n for i in range(2**n): op = ["P"] * n # あらかじめ ["P", "P", "P"] というリストを作っておく for j in range(n): if (i >> j) & 1: op[n - 1 - j] = "D" # フラグが立っていた箇所を "D" で上書き for i, e in enumerate(op): lis[temp[i]] = e LIS = "".join(lis) # print(t , LIS.count("PD")) if t < LIS.count("PD"): t = LIS.count("PD") List = LIS # print(t,LIS) else: pass print(List)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s578706735
Runtime Error
p02664
Input is given from Standard Input in the following format: T
# coding: utf-8 # Your code here! #########行列読み込み ############################################## """ from sys import stdin n = int(stdin.readline().rstrip()) data = [stdin.readline().rstrip().split() for _ in range(n)] print(data) print(*data, sep='\n') """ import itertools S = input() # print(S) S_copy = S i = S.count("?") tmp = list(itertools.product(["P", "D"], repeat=i)) # print(tmp) # print(tmp[0]) num = len(tmp[0]) ans = [] for x in range(len(tmp)): S = S_copy for y in tmp[x]: S = S.replace("?", y, 1) # print(S) ans.append(S) key = [] for i in ans: # print(type(i)) # print(type(i.count("PD"))) key.append(i.count("PD") + i.count("D")) # print(key) d = dict(zip(ans, key)) # print(d) max_k = max(d, key=d.get) print(max_k)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s227375173
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
# 文字列の入力 S_list = list(input()) # 最後の文字はD if S_list[len(S_list) - 1] == "?": S_list[len(S_list) - 1] = "D" # print("1",S_list) for i in range(len(S_list) - 1): if S_list[i] == "?": if S_list[i + 1] == "D": S_list[i] = "P" # print("2",S_list) elif S_list[i + 1] == "?": S_list[i] = "D" S_list[i + 1] = "D" # print("3",S_list) else: S_list[i] = "D" # print("4",S_list) print(*S_list, sep="")
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s958862001
Accepted
p02664
Input is given from Standard Input in the following format: T
moji = input() moji = moji.replace("?", "D") print(moji)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s208900283
Runtime Error
p02664
Input is given from Standard Input in the following format: T
print(input.replace("?", "D"))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s702222414
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
def main(): pass if __name__ == "__main__": main()
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s333237957
Runtime Error
p02664
Input is given from Standard Input in the following format: T
print(input().reaplce("?", "D"))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s121051960
Wrong Answer
p02664
Input is given from Standard Input in the following format: T
print(input().replace("?", "P"))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s331944141
Accepted
p02664
Input is given from Standard Input in the following format: T
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**19 MOD = 10**9 + 7 T = input() ans = T.replace("?", "D") print(ans)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s683737484
Accepted
p02664
Input is given from Standard Input in the following format: T
s = input().split() s_replace = [x.replace("?", "D") for x in s] print(s_replace[0])
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s053448670
Accepted
p02664
Input is given from Standard Input in the following format: T
a = str(input()) print(a.replace("?", "D"))
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each `?` in T with `P` or `D`. If there are multiple such strings, you may print any of them. * * *
s010057943
Accepted
p02664
Input is given from Standard Input in the following format: T
ln = input() ln1 = ln.replace("?", "D") print(ln1)
Statement For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3. We have a string T consisting of `P`, `D`, and `?`. Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.
[{"input": "PD?D??P", "output": "PDPDPDP\n \n\nThis string contains three occurrences of `D` and three occurrences of `PD` as\ncontiguous substrings, so its doctoral and postdoctoral quotient is 6, which\nis the maximum doctoral and postdoctoral quotient of a string obtained by\nreplacing each `?` in T with `P` or `D`.\n\n* * *"}, {"input": "P?P?", "output": "PDPD"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s759112335
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
import numpy as np from itertools from functools import reduce from collections import defaultdict N = int(input()) d = defaultdict(int) for i in range(N): c = input() if c[0] in ('M', 'A', 'R', 'C', 'H'): d[c[0]] += 1 l = len(d) if l < 3: print(0) else: ans = 0 for l in list(itertools.combinations(d.values(), 3)): ans += reduce(np.multiply, l) print(ans)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s778935506
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int n = int.Parse(ReadLine()); List<string> s = new List<string>(); for (int i=0;i<n;i++) { s.Add(ReadLine()); } var hashSet = new HashSet<string>(s); s = hashSet.ToList(); List<int> ans = new List<int>(); for (int i=0;i<5;i++) { ans.Add(0); } for (int i=0;i<s.Count;i++) { if (s[i].Substring(0,1)=="M") { ans[0]+=1; } else if (s[i].Substring(0,1)=="A") { ans[1]+=1; } else if (s[i].Substring(0,1)=="R") { ans[2]+=1; } else if (s[i].Substring(0,1)=="C") { ans[3]+=1; } else if (s[i].Substring(0,1)=="H") { ans[4]+=1; } } int answ=0; for (int i=0;i<5;i++) { for (int j=i+1;j<5;j++) { for (int k=j+1;k<5;k++) { if (i!=j && j!=k && i!=k) { answ+=ans[i]*ans[j]*ans[k]; } } } } WriteLine(answ); } }
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s150130224
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
############################################################################### 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 class UnionFind: def __init__(self, n): self.parent = [i for i in range(n)] def root(self, i): if self.parent[i] == i: return i self.parent[i] = self.root(self.parent[i]) return self.parent[i] def unite(self, i, j): rooti = self.root(i) rootj = self.root(j) if rooti == rootj: return if rooti < rootj: self.parent[rootj] = rooti else: self.parent[rooti] = rootj def same(self, i, j): return self.root(i) == self.root(j) ############################################################################### def main(): n = intin() slist = [input() for _ in range(n)] count = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for s in slist: if s[0] in count: count[s[0]] += 1 patterns = [ ["M", "A", "R"], ["M", "A", "C"], ["M", "A", "H"], ["M", "R", "C"], ["M", "R", "H"], ["M", "C", "H"], ["A", "R", "C"], ["A", "R", "H"], ["A", "C", "H"], ["R", "C", "H"], ] ans = 0 for p in patterns: ans += count[p[0]] * count[p[1]] * count[p[2]] print(ans) if __name__ == "__main__": main()
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s828931161
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
N = int(input()) S = {"M":0,"A":0,"R":0,"C":0,"H":0} for i in range(N): s = input() if s[0] in ["M","A","R","C","H"] S[s[0]] += 1 print(S["M"] * S["A"] * (S["R"]+S["C"]+S["H"]) + S["M"] * S["R"] * (S["C"] + S["H"]) + S["M"] * S["C"] * S["H"] + S["A"] * S["R"] * (S["C"] + S["H"]) + S["C"] * S["A"] * S["H"] + S["R"] * S["C"] * S["H"])
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s117634450
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
n=int(input()) m,a,r,c,h=0,0,0,0,0 for i in range(n): s=input() if s[0]=='M': m+=1 elif s[0]=='A': a+=1 elif s[0]=='R': r+=1 elif s[0]=='C': c+=1 elif s[0]=='H': h+=1 x=del ([m,a,r,c,h],0) x.sort() l=len(x) if l<3: print(0) elif l==3: print(x[0]*x[1]*x[2]) elif l==4: print() else: print()
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s686094722
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
m,a,r,c,h = [0,0,0,0,0] N = int(input()) for i in range(N):
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s538617656
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
from itertools import * N, *S = open(0) print( sum( a * b * c for a, b, c in combinations(sum(1 for s in S if s[0] == c) for c in "MARCH", 3) ) )
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s334828320
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
from itertools import combinations import collections N = int(input()) A = [] for i in range(N): A.append(input()[0]) AA = set(A) C = collections.Counter(A) print(sum(C[a]*C[b]*C[c] for a, b, c combinations(AA, 3)))
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s340392411
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
from itertools import * N, *S = open(0) print( sum( a * b * c for a, b, c in combinations(sum(1 for s in S if s[0] == c) for c in "MARCH", 3) ) )
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s563414200
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<queue> #include<map> #include<math.h> #define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++) #define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--) #define INF 100000000 #define MOD 1000000007 typedef long long ll; using namespace std; double euclid_distance(double a,double b){ return sqrt(a*a+b*b); } int gcd(long long int a,long long int b){ long long int r; if(a < b){ int tmp; tmp = a; a = b; b = tmp; } while(r != 0){ r = a % b; a = b; b = r; } return r; } void Integer_factorization(ll factor[],ll n){ ll a = 2; bool flag = false; for(int p = 2;p*p <= n;p++){ while(n%p == 0){ n/=p; factor[p]++; } } if(n!=1) factor[n]++; //prime num } void ys(){ cout << "Yes" << endl; } void yb(){ cout << "YES" << endl; } void ns(){ cout << "No" << endl; } void nb(){ cout << "NO" << endl; } void solve(void){ ll n; cin >> n; ll d[5] = {0}; int a[10] = {0,0,0,0,0,0,1,1,1,2}; int b[10] = {1,1,1,2,2,3,2,2,3,3}; int c[10] = {2,3,4,3,4,4,3,4,4,4}; rep(i,0,n){ string s; cin >> s; if(s[0] == 'M') d[0]++; if(s[0] == 'A') d[1]++; if(s[0] == 'R') d[2]++; if(s[0] == 'C') d[3]++; if(s[0] == 'H') d[4]++; } ll ans = 0; rep(i,0,10){ ans += d[a[i]]*d[b[i]]*d[c[i]]; } cout << ans <<endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); solve(); }
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s779161061
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
n = int(input().strip()) s = [input().strip() for _ in range(n)] num_m = len([True for _s in s if _s[0] == "M"]) num_a = len([True for _s in s if _s[0] == "A"]) num_r = len([True for _s in s if _s[0] == "R"]) num_c = len([True for _s in s if _s[0] == "C"]) num_h = len([True for _s in s if _s[0] == "H"]) print(num_m * num_a * num_r + num_m * num_a * num_c + num_m * num_a * num_h + num_m * num_r * num_c + num_m * num_r * num_h + num_m * num_c * num_h + num_a * num_r * num_c + num_a * num_r * num_h + num_a * num_c * num_h + num_r * num_c * num_h
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s011305958
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
n = int(input().strip()) s = [input().strip() for _ in range(n)] num = [0 for _ in range(5)] num[0] = len([True for _s in s if _s[0] == "M"]) num[1] = len([True for _s in s if _s[0] == "A"]) num[2] = len([True for _s in s if _s[0] == "R"]) num[3] = len([True for _s in s if _s[0] == "C"]) num[4] = len([True for _s in s if _s[0] == "H"]) ans = 0 for i in range(5): for j in range(i, 5): for k in range(j, 5): ans += num[i] * num[j] * num[k] print(ans
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s516722740
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
import itertools N = int(input()) SK = {"M":0,"A":1,"R":2,"C":3,"H":4} SD = [0]*5 del_list = [] A = ["M","A","R","C","H"] for x in range(N): tmp = str(input()) if tmp[0] in A: SD[SK[tmp[0]]] +=1 C = 0 for x in range(5) if SD[x] == 0 : del_list.append(x) C +=1 del_list.reverse() for x in del_list: SD.pop(x) if C >2: print(0) else: Z = 5-C k = itertools.combinations(range(Z), 3) ans = 0 for x in k: ans += SD[x[0]]*SD[x[1]]*SD[x[2]] print(ans)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s361694075
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
import itertools as it def c(n,k): if k>n: return 0 ret = 1 for i in range(n, n-k, -1): ret *= i for i in range(k, 1, -1): ret /= i return ret n = int(input()) dic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0} for person in range(n): name = input() if name[0] in 'MARCH': dic[name[0]] += 1 answer = 0 for a,b,c = it.combinations('MARCH', 3): answer += dic[a] * dic[b] * dic[c] print(answer)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s858135613
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
if __name__ == "__main__": N = int(input()) M = [] A = [] R = [] C = [] H = [] for i in range(N): buf = str(input()) if buf[0] == "M": M.append(buf) elif buf[0] == "A": A.append(buf) elif buf[0] == "R": R.append(buf) elif buf[0] == "C": C.append(buf) elif buf[0] == "H": H.append(buf) M_cnt = len(M) A_cnt = len(A) R_cnt = len(R) C_cnt = len(C) H_cnt = len(H) # obj = {'M':M_cnt, 'A':A_cnt, 'R':R_cnt, 'C':C_cnt, 'H':H_cnt} cnt = ( M_cnt * A_cnt * R_cnt + M_cnt * A_cnt * C_cnt + M_cnt * A_cnt * H_cnt + M_cnt * R_cnt * C_cnt + M_cnt * R_cnt * H_cnt + M_cnt * C_cnt * H_cnt + A_cnt * R_cnt * C_cnt + A_cnt * R_cnt * H_cnt + A_cnt * C_cnt * H_cnt + R_cnt * C_cnt * H_cnt ) print(cnt)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s462440038
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
N = int(input()) S = [str(input()) for i in range(N)] S_head = [] for i in S: S_head.append(i[:1]) M_num = S_head.count("M") A_num = S_head.count("A") R_num = S_head.count("R") C_num = S_head.count("C") H_num = S_head.count("H") ans = ( M_num * A_num * R_num + M_num * A_num * C_num + M_num * A_num * H_num + M_num * R_num * C_num + M_num * R_num * H_num + M_num * C_num * H_num + A_num * R_num * C_num + A_num * R_num * H_num + A_num * C_num * H_num + R_num * C_num * H_num ) print(ans)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s125664156
Runtime Error
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
# -*- coding: utf-8 -*- import sys import copy import collections from bisect import bisect_left from bisect import bisect_right from collections import defaultdict from heapq import heappop, heappush import math # NO, PAY-PAY #import numpy as np #import statistics #from statistics import mean, median,variance,stdev def main(): N = int(input()) s = [] for i in range(N): tmp = input() s.append(tmp) m = 0 a = 0 r = 0 c = 0 h = 0 for i in s: if s[0] == "M": m += 1 elif s[0] == "A": a += 1 elif s[0] == "R": r += 1 elif s[0] == "C": c += 1 elif s[0] == "H": h += 1e ans = 0 total = (a*b*c) + (a*b*d) + (a*b*e) + (a*c*d) + (a*c*e) + (a*d*e) + (b*c*d) + (b*c*e) + (b*d*e) + (c*d*e) print(total) if __name__ == "__main__": main()
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s019212682
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
n = int(input()) ss = {} for i in range(n): s = input() if s[0] in ["M", "A", "R", "C", "H"]: if s[0] in ss.keys(): ss[s[0]] += 1 else: ss[s[0]] = 1 sss = list(ss.values()) res = 0 if len(ss.keys()) <= 2: res = 0 elif len(ss.keys()) == 3: res = sss[0] * sss[1] * sss[2] elif len(ss.keys()) == 4: res = ( sss[0] * sss[1] * sss[2] + sss[0] * sss[1] * sss[3] + sss[0] * sss[2] * sss[3] + sss[1] * sss[2] * sss[3] ) elif len(ss.keys()) == 5: res = ( sss[0] * sss[1] * sss[2] + sss[0] * sss[1] * sss[3] + sss[0] * sss[1] * sss[4] + sss[0] * sss[2] * sss[3] + sss[0] * sss[2] * sss[4] + sss[0] * sss[3] * sss[4] + sss[1] * sss[2] * sss[3] + sss[1] * sss[2] * sss[4] + sss[1] * sss[3] * sss[4] + sss[2] * sss[3] * sss[4] ) print(res)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s399496869
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
N = int(input()) n = {} n["M"] = 0 n["A"] = 0 n["R"] = 0 n["C"] = 0 n["H"] = 0 heads = ["M", "A", "R", "C", "H"] for _ in range(N): s = input() if heads.count(s[0]) == 1: n[s[0]] += 1 ans = ( n["M"] * n["A"] * n["R"] + n["M"] * n["A"] * n["C"] + n["M"] * n["A"] * n["H"] + n["M"] * n["R"] * n["C"] + n["M"] * n["R"] * n["H"] + n["M"] * n["C"] * n["H"] + n["A"] * n["R"] * n["C"] + n["A"] * n["R"] * n["H"] + n["A"] * n["C"] * n["H"] + n["R"] * n["C"] * n["H"] ) print(ans)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s344240344
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
import collections def a(): return input() # s def ai(): return int(input()) # a,n or k def ma(): return map(int, input().split()) # a,b,c,d or n,k def ms(): return map(str, input().split()) # ,a,b,c,d def lma(): return list(map(int, input().split())) # x or y def lms(): return list(map(str, input().split())) # x or y k = [] l = [] f = 0 def say(i): return print("Yes" if i == 0 else "No") def Say(i): return print("YES" if i == 0 else "NO") # def rep(i):return for i in range() def addarray(k, l): for i in range(n): a, b = map(int, input().split()) w.append(b) v.append(a) a = ai() for i in range(a): b = input() if b[0] in ["M", "A", "R", "C", "H"]: k.append(b[0]) q = collections.Counter(k) p = list(q.values()) if len(p) == 3: print(p[0] * p[1] * p[2]) elif len(p) == 4: print( p[0] * p[1] * p[2] + p[0] * p[1] * p[3] + p[0] * p[3] * p[2] + p[3] * p[1] * p[2] ) elif len(p) == 5: print( p[0] * p[1] * p[2] + p[0] * p[1] * p[3] + p[0] * p[1] * p[4] + p[0] * p[2] * p[3] + p[3] * p[0] * p[4] + p[1] * p[2] * p[3] + p[4] * p[1] * p[2] + p[3] * p[1] * p[4] + p[2] * p[3] * p[4] + p[0] * p[2] * p[4] ) else: print(0)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s494784299
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
N = int(input()) d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for _ in range(N): c = input()[0] if c in "MARCH": d[c] += 1 gl = [ d["M"] * d["A"] * d["R"], d["M"] * d["A"] * d["C"], d["M"] * d["A"] * d["H"], d["M"] * d["R"] * d["C"], d["M"] * d["R"] * d["H"], d["M"] * d["C"] * d["H"], d["A"] * d["R"] * d["C"], d["A"] * d["R"] * d["H"], d["A"] * d["C"] * d["H"], d["R"] * d["C"] * d["H"], ] print(sum(gl))
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s995054314
Accepted
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
n = int(input("")) s = ["0"] * n dict = {} sum = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ans = 0 for i in range(n): s[i] = input("") if s[i][0] in "MARCH": if s[i][0] in dict: dict[s[i][0]] += 1 else: dict[s[i][0]] = 1 if "M" in dict: if "A" in dict: if "R" in dict: sum[0] = dict["M"] * dict["A"] * dict["R"] if "C" in dict: sum[1] = dict["M"] * dict["A"] * dict["C"] if "H" in dict: sum[2] = dict["M"] * dict["A"] * dict["H"] if "R" in dict: if "C" in dict: sum[3] = dict["M"] * dict["R"] * dict["C"] if "H" in dict: sum[4] = dict["M"] * dict["R"] * dict["H"] if "C" in dict: if "H" in dict: sum[5] = dict["M"] * dict["C"] * dict["H"] if "A" in dict: if "R" in dict: if "C" in dict: sum[6] = dict["A"] * dict["R"] * dict["C"] if "H" in dict: sum[7] = dict["A"] * dict["R"] * dict["H"] if "C" in dict: if "H" in dict: sum[8] = dict["A"] * dict["C"] * dict["H"] if "R" in dict and "C" in dict and "H" in dict: sum[9] = dict["R"] * dict["C"] * dict["H"] for i in range(10): ans += sum[i] print(ans)
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
If there are x ways to choose three people so that the given conditions are met, print x. * * *
s581191383
Wrong Answer
p03425
Input is given from Standard Input in the following format: N S_1 : S_N
def resolve(): n = int(input()) x = 0 s = [input() for __ in range(n)] m = [i for i in s if i[0] == "M"] a = [i for i in s if i[0] == "A"] r = [i for i in s if i[0] == "R"] c = [i for i in s if i[0] == "C"] h = [i for i in s if i[0] == "H"] mm = len(m) aa = len(a) rr = len(r) cc = len(c) hh = len(h) print( mm * aa * (rr + cc + hh) + mm * rr * (cc + hh) + mm * cc * hh + aa * rr * (cc + hh) + rr * cc * hh ) resolve()
Statement There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type.
[{"input": "5\n MASHIKE\n RUMOI\n OBIRA\n HABORO\n HOROKANAI", "output": "2\n \n\nWe can choose three people with the following names:\n\n * `MASHIKE`, `RUMOI`, `HABORO`\n\n * `MASHIKE`, `RUMOI`, `HOROKANAI`\n\nThus, we have two ways.\n\n* * *"}, {"input": "4\n ZZ\n ZZZ\n Z\n ZZZZZZZZZZ", "output": "0\n \n\nNote that there may be no ways to choose three people so that the given\nconditions are met.\n\n* * *"}, {"input": "5\n CHOKUDAI\n RNG\n MAKOTO\n AOKI\n RINGO", "output": "7"}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s650282147
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
# abc123_a.py # https://atcoder.jp/contests/abc123/tasks/abc123_a # ★ WA:2 # in2.txt # in3.txt # A - Five Antennas / # 実行時間制限: 2 sec / メモリ制限: 1024 MB # 配点: 100点 # 問題文 # AtCoder 市には、5つのアンテナが一直線上に並んでいます。 # これらは、西から順にアンテナ A,B,C,D,E と名付けられており、それぞれの座標は a,b,c,d,e です。 # 2 つのアンテナ間の距離が k 以下であれば直接通信ができ、k より大きいと直接通信ができません。 # さて、直接 通信ができないアンテナの組が存在するかどうか判定してください。 # ただし、座標 p と座標 q (p<q) のアンテナ間の距離は q−pであるとします。 # 制約 # a,b,c,d,e,kは 0 以上 123以下の整数 # a<b<c<d<e # 入力 # 入力は以下の形式で標準入力から与えられる。 # a # b # c # d # e # k # 出力 # 直接 通信ができないアンテナの組が存在する場合は :(、存在しない場合は Yay! と出力せよ。 # 入力例 1 # 1 # 2 # 4 # 8 # 9 # 15 # 出力例 1 # Yay! # この場合、直接通信できないアンテナの組は存在しません。なぜなら、 # (A,B)の距離は 2−1 = 1 # (A,C)の距離は 4−1 = 3 # (A,D)の距離は 8−1 = 7 # (A,E)の距離は 9−1 = 8 # (B,C)の距離は 4−2 = 2 # (B,D)の距離は 8−2 = 6 # (B,E)の距離は 9−2 = 7 # (C,D)の距離は 8−4 = 4 # (C,E)の距離は 9−4 = 5 # (D,E)の距離は 9−8 = 1 # そのように、全てのアンテナ間の距離が 15以下であるからです。 # よって、Yay! と出力すれば正解となります。 # 入力例 2 # 15 # 18 # 26 # 35 # 36 # 18 # 出力例 2 # :( # この場合、アンテナ A # と D の距離が 35−15 = 20 となり、18 を超えるため直接通信ができません。 # よって、:( と出力すれば正解となります。 global FLAG_LOG FLAG_LOG = False def log(value): # FLAG_LOG = True # FLAG_LOG = False if FLAG_LOG: print(str(value)) def calculation(lines): # line = lines[0] # N = int(lines[0]) # N, Q = list(map(int, lines[0].split())) # values = list(map(int, lines[1].split())) # values = list(map(int, lines[1].split())) values = list() for i in range(5): values.append(int(lines[i])) # valueses = list() # for i in range(Q): # valueses.append(list(map(int, lines[i+1].split()))) log(f"lines[5]=[{lines[5]}]") for i in range(4): for j in range(4): log( f"values[i]=[{values[i]}], values[j]=[{values[j]}], lines[5]=[{lines[5]}]" ) log( f"abs(values[i] - values[j])=[{abs(values[i] - values[j])}], int(lines[5])=[{int(lines[5])}]" ) if abs(values[i] - values[j]) >= int(lines[5]): return [":("] return ["Yay!"] # 引数を取得 def get_input_lines(lines_count): lines = list() for _ in range(lines_count): lines.append(input()) return lines # テストデータ def get_testdata(pattern): if pattern == 1: lines_input = ["1", "2", "4", "8", "9", "15"] lines_export = ["Yay!"] if pattern == 2: lines_input = ["15", "18", "26", "35", "36", "18"] lines_export = [":("] return lines_input, lines_export # 動作モード判別 def get_mode(): import sys args = sys.argv global FLAG_LOG if len(args) == 1: mode = 0 FLAG_LOG = False else: mode = int(args[1]) FLAG_LOG = True return mode # 主処理 def main(): import time started = time.time() mode = get_mode() if mode == 0: lines_input = get_input_lines(6) else: lines_input, lines_export = get_testdata(mode) lines_result = calculation(lines_input) for line_result in lines_result: print(line_result) if FLAG_LOG: log(f"lines_input=[{lines_input}]") log(f"lines_export=[{lines_export}]") log(f"lines_result=[{lines_result}]") if lines_result == lines_export: log("OK") else: log("NG") finished = time.time() duration = finished - started log(f"duration=[{duration}]") # 起動処理 if __name__ == "__main__": main()
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s746071798
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() # ignore trailing spaces ab = [] res = [] x, y, z, k = na() a_li = na() b_li = na() c_li = na() for a in a_li: for b in b_li: ab.append((a * b)) list.sort(ab, reverse=True) list.sort(c_li, reverse=True) for a_b in ab: for c in c_li: res.append(a_b * c) for num in sorted(res, reverse=True)[-k:]: print(num)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s517293843
Accepted
p03075
Input is given from Standard Input in the following format: a b c d e k
a, _, _, _, e, k = [int(input()) for _ in range(6)] print(["Yay!", ":("][e - a > k])
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s158658155
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
a, _, _, _, e, k = [int(input()) for i in range(6)] print(":(" if e - a >= k else "Yay!")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s193720346
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
0
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s891831174
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
x, y = [], [] t = 10 for i in range(5): x.append(int(input())) y.append(x[i] % 10) if 0 < y[i] < t: t = y[i] if x[i] % 10 != 0: x[i] = ((x[i] // 10) + 1) * 10 y[i] = x[i] print(sum(y) + t - 10)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s060071185
Accepted
p03075
Input is given from Standard Input in the following format: a b c d e k
aek = [int(input()) for _ in range(6)] print("Yay!" if aek[4] - aek[0] <= aek[5] else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s551822912
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
a, b, c, d, e, k = (int(x) for x in input().split() if e-a <= k: print("Yay!") else: print(":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s322265318
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
a = sorted([int(input()) for _ in range(5)]) ls = sorted([a[i + 1] - a[i] for i in range(4)]) print("Yay!" if ls[4] < input() else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s761989385
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
n = [] for _ in range(6): n += [int(input())] print(["Yey!", ":("][n[4] - n[0] > n[5]])
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s248881294
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) println(e - a <= k ? "Yay!" : ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s937343638
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
import math a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) if a >= 100: a1 = a % 10 else: a2 = a - 100 a1 = a2 % 10 if b >= 100: b1 = b % 10 else: b2 = b - 100 b1 = b2 % 10 if c >= 100: c1 = c % 10 else: c2 = c - 100 c1 = c2 % 10 if d >= 100: d1 = d % 10 else: d2 = d - 100 d1 = d2 % 10 if e >= 100: e1 = e % 10 else: e2 = e - 100 e1 = e2 % 10 if a1 == 0: a1 = 9 if b1 == 0: b1 = 9 if c1 == 0: c1 = 9 if d1 == 0: a1 = 9 if e1 == 0: e1 = 9 lis = [a1, b1, c1, d1, e1] if a1 == min(lis): answer = ( math.ceil(b / 10) * 10 + math.ceil(c / 10) * 10 + math.ceil(e / 10) * 10 + math.ceil(d / 10) * 10 + a ) if b1 == min(lis): answer = ( math.ceil(a / 10) * 10 + math.ceil(c / 10) * 10 + math.ceil(e / 10) * 10 + math.ceil(d / 10) * 10 + b ) if c1 == min(lis): answer = ( math.ceil(b / 10) * 10 + math.ceil(a / 10) * 10 + math.ceil(e / 10) * 10 + math.ceil(d / 10) * 10 + c ) if d1 == min(lis): answer = ( math.ceil(b / 10) * 10 + math.ceil(c / 10) * 10 + math.ceil(e / 10) * 10 + math.ceil(a / 10) * 10 + d ) if e1 == min(lis): answer = ( math.ceil(b / 10) * 10 + math.ceil(c / 10) * 10 + math.ceil(e / 10) * 10 + math.ceil(a / 10) * 10 + e ) print(answer)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s226352743
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) n = 0 if e-a > k or e-b > k or d-a > k or e-c > k or d-b > k or c-a > k or e-d > k or d-c > k or c-b > k or b-a > k: n = 1 if n = 1: print(":(") if n = 0: print("Yay!")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s228352453
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) if b - a <= k and c - b <= k and d - c <= k and e - d <= k and c - a <= k and d - a <= k and e - a <= k and d - b <= k and e - b <= k and e - c <= k: print("Yay! ") else: print(": (")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s286731075
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
times = [int(input()) for _ in range(5)] times1 = [] total = 0 for t in times: t1 = t % 10 if t1 == 0: total += t else: times1.append(t1) total += (t // 10 + 1) * 10 if len(times1) >= 1: total = total + min(times1) - 10 print(total)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s757322623
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
i = [int(input()) for _ in range(6)] o = ":(" if i[0] - i[4] > i[5] else "Yay!" print(o)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s225348809
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
C = list() for i in range(6): coo.append(int(input())) if coo[4] - coo[0] > coo[5]: print(":(") else: print("Yay!")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s440035165
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
15 18 26 35 36 18
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s392588808
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
data = [int(input()) for i in range(6)] print("Yay!" if data[-2] - data[0] < data[-1] else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s094578247
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
inputs = input() print(input)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s455048554
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
a, b, c, d, e = [int(input()) for i in range(5)] a1 = a // 10 a2 = a % 10 if a2 == 0: a1 -= 1 a2 = 10 b1 = b // 10 b2 = b % 10 if b2 == 0: b1 -= 1 b2 = 10 c1 = c // 10 c2 = c % 10 if c2 == 0: c1 -= 1 c2 = 10 d1 = d // 10 d2 = d % 10 if d2 == 0: d1 -= 1 d2 = 10 n = e // 10 m = e % 10 if m == 0: n -= 1 m = 10 min1 = min(a2, b2, c2, d2, m) if a2 == 10 or b2 == 10 or c2 == 10 or d2 == 10 or m == 10: ans = (a1 + b1 + c1 + d1 + n + 5) * 10 + min1 else: ans = (a1 + b1 + c1 + d1 + n + 4) * 10 + min1 print(ans)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s372726344
Accepted
p03075
Input is given from Standard Input in the following format: a b c d e k
A = [int(input()) for i in range(5)] print("Yay!" if A[4] - A[0] <= int(input()) else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s336594511
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
import heapq X, Y, Z, K = map(int, input().split()) A = sorted(list(map(int, input().split())))[::-1] B = sorted(list(map(int, input().split())))[::-1] C = sorted(list(map(int, input().split())))[::-1] default = A[0] + B[0] + C[0] A = [A[0] - A[i] for i in range(len(A))] B = [B[0] - B[i] for i in range(len(B))] C = [C[0] - C[i] for i in range(len(C))] print(default) hp = [] visited = set() visited.add((0, 0, 0)) a, b, c = 0, 0, 0 for _ in range(K - 1): if (a + 1, b, c) not in visited and a + 1 < len(A): heapq.heappush(hp, (A[a + 1] + B[b] + C[c], (a + 1, b, c))) visited.add((a + 1, b, c)) if (a, b + 1, c) not in visited and b + 1 < len(B): heapq.heappush(hp, (A[a] + B[b + 1] + C[c], (a, b + 1, c))) visited.add((a, b + 1, c)) if (a, b, c + 1) not in visited and c + 1 < len(C): heapq.heappush(hp, (A[a] + B[b] + C[c + 1], (a, b, c + 1))) visited.add((a, b, c + 1)) temp = heapq.heappop(hp) print(default - temp[1]) a, b, c = temp[2]
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s118104281
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
import sys a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) flag = 0 if((e-d)=<k): if((d-c)=<k): if((c-b)=<k): if((b-a)=<k): print("Yay!") flag = 1 if(flag == 1): print(":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s058079406
Accepted
p03075
Input is given from Standard Input in the following format: a b c d e k
a = list(map(int, open(0))) print(["Yay!", ":("][max(a[:5]) - min(a[:5]) > a[5]])
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s645992962
Accepted
p03075
Input is given from Standard Input in the following format: a b c d e k
l = [int(input()) for i in range(6)] print("Yay!" if l[4] - l[0] <= l[5] else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s983764217
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
*a, k = [int(input()) for _ in range(6)] print("Yay!" if max(a) - min(a) < k else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s140898967
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
l = [int(input()) for i in range(6)] if l[4] - l[0] =< l[5]: print("Yay!") else: print(":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s886289819
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
N = int(input()) A = [int(input()) for i in range(5)] ans = N // min(A) if N % min(A) != 0: ans += 1 print(ans + 4)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s630892349
Accepted
p03075
Input is given from Standard Input in the following format: a b c d e k
inpl = [] inpl.append(int(input())) inpl.append(int(input())) inpl.append(int(input())) inpl.append(int(input())) inpl.append(int(input())) d = int(input()) print(":(" if d < (max(inpl) - min(inpl)) else "Yay!")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s127427808
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) f=int(input()) if e - a <= f: print('Yay!') else print(':(')
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s205417339
Wrong Answer
p03075
Input is given from Standard Input in the following format: a b c d e k
Li = list(int(input()) for _ in range(6)) F = [1 for i in range(4) for j in range(i, 4) if abs(Li[j] - Li[i]) < Li[5]] print("Yay!" if len(F) == 10 else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s034582529
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
a = int(input()) _ = int(input()) _ = int(input()) _ = int(input()) e = int(input()) k = int(input()) if e - a =< k: print("Yay!") else: print(":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s853713128
Runtime Error
p03075
Input is given from Standard Input in the following format: a b c d e k
# https://img.atcoder.jp/abc123/editorial.pdf # 問題D: Cake 123 解法 #3 - さらに高速な解法、priority-queue を用いて O(K log K) from heapq import heappush, nlargest def solve(X, Y, Z, K, A, B, C): A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) Q = [] for a in A: for b in B: heappush(Q, a + b) AB = nlargest(K, Q) Q2 = [] for ab in AB: for c in C: heappush(Q2, ab + c) ABC = nlargest(K, Q2) print("\n".join(map(str, ABC))) if __name__ == "__main__": X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) solve(X, Y, Z, K, A, B, C)
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print `:(` if there exists a pair of antennas that cannot communicate **directly** , and print `Yay!` if there is no such pair. * * *
s961421003
Accepted
p03075
Input is given from Standard Input in the following format: a b c d e k
i = 0 zahyou = [] while i < 6: zahyou.append(int(input())) i += 1 print("Yay!" if zahyou[4] - zahyou[0] <= zahyou[5] else ":(")
Statement In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively. Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k. Determine if there exists a pair of antennas that cannot communicate **directly**. Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.
[{"input": "1\n 2\n 4\n 8\n 9\n 15", "output": "Yay!\n \n\nIn this case, there is no pair of antennas that cannot communicate directly,\nbecause:\n\n * the distance between A and B is 2 - 1 = 1\n * the distance between A and C is 4 - 1 = 3\n * the distance between A and D is 8 - 1 = 7\n * the distance between A and E is 9 - 1 = 8\n * the distance between B and C is 4 - 2 = 2\n * the distance between B and D is 8 - 2 = 6\n * the distance between B and E is 9 - 2 = 7\n * the distance between C and D is 8 - 4 = 4\n * the distance between C and E is 9 - 4 = 5\n * the distance between D and E is 9 - 8 = 1\n\nand none of them is greater than 15. Thus, the correct output is `Yay!`.\n\n* * *"}, {"input": "15\n 18\n 26\n 35\n 36\n 18", "output": ":(\n \n\nIn this case, the distance between antennas A and D is 35 - 15 = 20 and\nexceeds 18, so they cannot communicate directly. Thus, the correct output is\n`:(`."}]
Print the answer. * * *
s058909198
Wrong Answer
p02808
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_K
mod = 10**9 + 7 M = 1000 fact = [1] * (M + 1) factinv = [1] * (M + 1) inv = [1] * (M + 1) for n in range(2, M + 1): fact[n] = n * fact[n - 1] % mod inv[n] = -inv[mod % n] * (mod // n) % mod factinv[n] = inv[n] * factinv[n - 1] % mod def comb(n, k): return fact[n] * factinv[k] * factinv[n - k] % mod N, K = map(int, input().split()) a = list(map(int, input().split())) dp = [[0] * (N + 1) for i in range(K + 1)] dp[0][0] = 1 for k in range(K): for n in range(1, N + 1): for i in range(min(a[k] + 1, n + 1)): dp[k + 1][n] += ( fact[a[k]] * factinv[a[k] - i] * fact[N - i] * factinv[N] * comb(n, i) * dp[k][n - i] ) dp[k + 1][n] %= mod ans = dp[-1][-1] for i in range(K): ans *= comb(N, a[i]) ans %= mod print(ans)
Statement There are N children, numbered 1,2,\ldots,N. In the next K days, we will give them some cookies. In the i-th day, we will choose a_i children among the N with equal probability, and give one cookie to each child chosen. (We make these K choices independently.) Let us define the _happiness_ of the children as c_1 \times c_2 \times \ldots \times c_N, where c_i is the number of cookies received by Child i in the K days. Find the expected happiness multiplied by \binom{N}{a_1} \times \binom{N}{a_2} \times \ldots \times \binom{N}{a_K} (we can show that this value is an integer), modulo (10^{9}+7).
[{"input": "3 2\n 3 2", "output": "12\n \n\n * On the first day, all the children 1, 2, and 3 receive one cookie.\n * On the second day, two out of the three children 1, 2, and 3 receive one cookie.\n * Their happiness is 4 in any case, so the expected happiness is 4. Print this value multiplied by \\binom{3}{3} \\times \\binom{3}{2}, which is 12.\n\n* * *"}, {"input": "856 16\n 399 263 665 432 206 61 784 548 422 313 848 478 827 26 398 63", "output": "337587117\n \n\n * Find the expected value multiplied by \\binom{N}{a_1} \\times \\binom{N}{a_2} \\times \\ldots \\times \\binom{N}{a_K}, modulo (10^9+7)."}]
Print the answer. * * *
s109653271
Accepted
p02808
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_K
P = 10**9 + 7 fa = [1] for i in range(1, 1010): fa.append(fa[-1] * i % P) fainv = [pow(fa[-1], P - 2, P)] for i in range(1, 1010)[::-1]: fainv.append(fainv[-1] * i % P) fainv = fainv[::-1] k = 70 kk = 1 << k nu = lambda L: int("".join([bin(kk + a)[-k:] for a in L[::-1]]), 2) st = lambda n: bin(n)[2:] + "0" li = lambda s: [ int(a, 2) % P if len(a) else 0 for a in [s[-(i + 1) * k - 1 : -i * k - 1] for i in range(N + 1)] ] N, K = map(int, input().split()) A = [int(a) for a in input().split()] X = [fa[N]] + [0] * N for a in A: X = li( st( nu(X) * nu( [ ( fainv[i] * fa[N - i] * fainv[a - i] * fainv[N - a] % P if i <= a else 0 ) for i in range(N + 1) ] ) ) ) print(X[-1])
Statement There are N children, numbered 1,2,\ldots,N. In the next K days, we will give them some cookies. In the i-th day, we will choose a_i children among the N with equal probability, and give one cookie to each child chosen. (We make these K choices independently.) Let us define the _happiness_ of the children as c_1 \times c_2 \times \ldots \times c_N, where c_i is the number of cookies received by Child i in the K days. Find the expected happiness multiplied by \binom{N}{a_1} \times \binom{N}{a_2} \times \ldots \times \binom{N}{a_K} (we can show that this value is an integer), modulo (10^{9}+7).
[{"input": "3 2\n 3 2", "output": "12\n \n\n * On the first day, all the children 1, 2, and 3 receive one cookie.\n * On the second day, two out of the three children 1, 2, and 3 receive one cookie.\n * Their happiness is 4 in any case, so the expected happiness is 4. Print this value multiplied by \\binom{3}{3} \\times \\binom{3}{2}, which is 12.\n\n* * *"}, {"input": "856 16\n 399 263 665 432 206 61 784 548 422 313 848 478 827 26 398 63", "output": "337587117\n \n\n * Find the expected value multiplied by \\binom{N}{a_1} \\times \\binom{N}{a_2} \\times \\ldots \\times \\binom{N}{a_K}, modulo (10^9+7)."}]
Print the answer. * * *
s862031570
Accepted
p02808
Input is given from Standard Input in the following format: N K a_1 a_2 \ldots a_K
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, K, *A = map(int, read().split()) MOD = 10**9 + 7 def cumprod(A, MOD=MOD): L = len(A) Lsq = int(L**0.5 + 1) A = np.resize(A, Lsq**2).reshape(Lsq, Lsq) for n in range(1, Lsq): A[:, n] *= A[:, n - 1] A[:, n] %= MOD for n in range(1, Lsq): A[n] *= A[n - 1, -1] A[n] %= MOD return A.ravel()[:L] def make_fact(U, MOD=MOD): x = np.arange(U, dtype=np.int64) x[0] = 1 fact = cumprod(x, MOD) x = np.arange(U, 0, -1, dtype=np.int64) x[0] = pow(int(fact[-1]), MOD - 2, MOD) fact_inv = cumprod(x, MOD)[::-1] return fact, fact_inv def convolve(f, g, MOD=MOD): """ 数列 (多項式) f, g の畳み込みの計算.上下 15 bitずつ分けて計算することで, 30 bit以下の整数,長さ 250000 程度の数列での計算が正確に行える. """ Lf = len(f) Lg = len(g) L = Lf + Lg - 1 fl = f & (1 << 15) - 1 fh = f >> 15 gl = g & (1 << 15) - 1 gh = g >> 15 if L < (1 << 8): conv = lambda f, g: np.convolve(f, g) % MOD else: fft = np.fft.rfft ifft = np.fft.irfft fft_len = 1 << L.bit_length() conv = ( lambda f, g: np.rint(ifft(fft(f, fft_len) * fft(g, fft_len))[:L]).astype( np.int64 ) % MOD ) x = conv(fl, gl) z = conv(fh, gh) y = conv(fl + fh, gl + gh) return (x + ((y - x - z) << 15) + (z << 30)) % MOD fact, fact_inv = make_fact(10**5) f = np.zeros(N + 1, np.int64) f[0] = 1 for a in A: g = fact[N - a : N + 1] * fact_inv[0 : a + 1] % MOD * fact_inv[N - a] % MOD g = g[::-1] g *= fact_inv[: len(g)] g %= MOD f = convolve(f, g)[: N + 1] f *= fact[: N + 1] f %= MOD answer = f[N] print(answer)
Statement There are N children, numbered 1,2,\ldots,N. In the next K days, we will give them some cookies. In the i-th day, we will choose a_i children among the N with equal probability, and give one cookie to each child chosen. (We make these K choices independently.) Let us define the _happiness_ of the children as c_1 \times c_2 \times \ldots \times c_N, where c_i is the number of cookies received by Child i in the K days. Find the expected happiness multiplied by \binom{N}{a_1} \times \binom{N}{a_2} \times \ldots \times \binom{N}{a_K} (we can show that this value is an integer), modulo (10^{9}+7).
[{"input": "3 2\n 3 2", "output": "12\n \n\n * On the first day, all the children 1, 2, and 3 receive one cookie.\n * On the second day, two out of the three children 1, 2, and 3 receive one cookie.\n * Their happiness is 4 in any case, so the expected happiness is 4. Print this value multiplied by \\binom{3}{3} \\times \\binom{3}{2}, which is 12.\n\n* * *"}, {"input": "856 16\n 399 263 665 432 206 61 784 548 422 313 848 478 827 26 398 63", "output": "337587117\n \n\n * Find the expected value multiplied by \\binom{N}{a_1} \\times \\binom{N}{a_2} \\times \\ldots \\times \\binom{N}{a_K}, modulo (10^9+7)."}]
For each line of input, output the corresponding sequence of characters in one line.
s002189204
Runtime Error
p00589
Input consists of several lines. Each line contains the sequence of button numbers without any spaces. You may assume one line contains no more than 10000 numbers. Input terminates with EOF.
keys = [ [" "], ["'", ",", ".", "!", "?"], ["a", "b", "c", "A", "B", "C"], ["d", "e", "f", "D", "E", "F"], ["g", "h", "i", "G", "H", "I"], ["j", "k", "l", "J", "K", "L"], ["m", "n", "o", "M", "N", "O"], ["p", "q", "r", "P", "Q", "R"], ["t", "u", "v", "T", "U", "V"], ["x", "y", "z", "X", "Y", "Z"], ] def main(): count = -1 data = input() before_number = data[0] output = [] for n in data: if before_number == n: count += 1 else: if before_number == "0": for zero in range(count): output.append(" ") else: output.append(keys[int(before_number)][count]) before_number = n count = 0 else: if before_number == "0": for zero in range(count): output.append(" ") else: output.append(keys[int(before_number)][count]) print("".join(output)) if __name__ == "__main__": while True: try: main() except EOFError: break
Extraordinary Girl (II) She loves e-mail so much! She sends e-mails by her cellular phone to her friends when she has breakfast, she talks with other friends, and even when she works in the library! Her cellular phone has somewhat simple layout (Figure 1). Pushing button 1 once displays a character (’), pushing ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_1003) it twice in series displays a character (,), and so on, and pushing it 6 times displays (’) again. Button 2 corresponds to charaters (abcABC), and, for example, pushing it four times displays (A). Button 3-9 have is similar to button 1. Button 0 is a special button: pushing it once make her possible to input characters in the same button in series. For example, she has to push “20202” to display “aaa” and “660666” to display “no”. In addition, pushing button 0 n times in series (n > 1) displays n − 1 spaces. She never pushes button 0 at the very beginning of her input. Here are some examples of her input and output: 666660666 --> No 44444416003334446633111 --> I’m fine. 20202202000333003330333 --> aaba f ff One day, the chief librarian of the library got very angry with her and hacked her cellular phone when she went to the second floor of the library to return books in shelves. Now her cellular phone can only display button numbers she pushes. Your task is to write a program to convert the sequence of button numbers into correct characters and help her continue her e-mails!
[{"input": "44444416003334446633111\n 20202202000333003330333", "output": "No\n I'm fine.\n aaba f ff"}]
Print the string displayed in the editor in the end. * * *
s925160120
Runtime Error
p04030
The input is given from Standard Input in the following format: s
s = input() txt = [] for c in s: if c == 'B' and len(txt) > 0: txt.pop() elif: txt.append(c) print(''.join(txt))
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s647919820
Wrong Answer
p04030
The input is given from Standard Input in the following format: s
nyu = input() shutu = [] for i in nyu: if i == "0" or "1": shutu.append(i) else: if len(shutu) != 0: shutu.pop(-1) kekka = "".join(shutu) print(kekka)
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s496646366
Runtime Error
p04030
The input is given from Standard Input in the following format: s
= list(input()) str = "" for i in range(len(s)): if s[i] == "0": str += "0" if s[i] == "1": str += "1" print(str) if s[i] == "B": if str == "": continue else: str = str[:-1] print(str)
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s574023769
Runtime Error
p04030
The input is given from Standard Input in the following format: s
S = list(input()) stack = [] stack.append(S.pop(0)) for s in S: if s == "B": if len(stack) > 0: stack.pop() else: stack.append(s) print("".join(stack)
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s682084941
Wrong Answer
p04030
The input is given from Standard Input in the following format: s
S = input() Z = "".join(list(S)) Z = Z.replace("0B", "") Z = Z.replace("1B", "") Z = Z.replace("B", "") print(Z)
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s651677621
Runtime Error
p04030
The input is given from Standard Input in the following format: s
r = [] for i in input(): if 'B' == i: if r: r.pop() else: r.append(i) print(''.join(r)
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s018223737
Runtime Error
p04030
The input is given from Standard Input in the following format: s
s=input() ans='' for x in s: if ans<>'': if x=='B' ans=ans[:-1] continue if x<>'B': ans+=x print(ans)
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s751752658
Accepted
p04030
The input is given from Standard Input in the following format: s
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # 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:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def bisearch(L, target): low = 0 high = len(L) - 1 while low <= high: mid = (low + high) // 2 guess = L[mid] if guess == target: return True elif guess < target: low = mid + 1 elif guess > target: high = mid - 1 if guess != target: return False # -------------------------------------------- dp = None def main(): S = input() R = "" for s in S: if s == "B": if len(R) >= 1: R = R[:-1] else: R += s print(R) main()
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]
Print the string displayed in the editor in the end. * * *
s309066160
Accepted
p04030
The input is given from Standard Input in the following format: s
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) 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_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_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/abc043/tasks/abc043_b S = input() ans = [] for s in S: if s == "B": if ans: del ans[-1] else: ans.append(s) print("".join(ans))
Statement Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
[{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}]